/**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  $data \Application\Model\CommercialGroupModel
  * @param  $context \Application\Model\CommercialGroupModel The original commercialGroup
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!$data instanceof CommercialGroupModel) {
         $this->_messages = array();
         $this->_messages[self::NOT_COMMERCIAL_GROUP] = $this->_messageTemplatesCommercialGroup[self::NOT_COMMERCIAL_GROUP];
         return false;
     }
     //check if is an update
     if ($data->getId()) {
         //check if the user have modified the service pack
         $cgMapper = CommercialGroupMapper::getInstance();
         $original = $cgMapper->findOneById($data->getId());
         if (!$original instanceof CommercialGroupModel) {
             throw new \Application\Exceptions\UnexpectedException("Commercial group Id doesn't exist for update operation");
         }
         if (!is_null($data->getServicePackId()) && $data->getServicePackId() !== $original->getServicePackId()) {
             if ($original->getSubscriberCount() !== 0) {
                 $this->_messages = array();
                 $this->_messages[self::COMMERCIAL_GROUP_HAVE_SUBSCRIPTIONS] = $this->_messageTemplatesCommercialGroup[self::COMMERCIAL_GROUP_HAVE_SUBSCRIPTIONS];
                 return false;
             }
         }
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof TransitionModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_TRANSITION] = $this->_messageTemplatesUser[self::NOT_TRANSITION];
         return false;
     }
     if ($data instanceof TransitionModel) {
         $autoInfo = $data->getAutomaticInfo();
         $auto = $data->getAutomatic();
         $manual = $data->getManual();
     } else {
         $autoInfo = isset($data['automaticInfo']) ? $data['automaticInfo'] : null;
         $auto = isset($data['automatic']) ? $data['automatic'] : false;
         $manual = isset($data['manual']) ? $data['manual'] : false;
     }
     if ($auto && !$autoInfo) {
         $this->_messages = array();
         $this->_messages[self::NOT_TRANSITION_AUTO_INFO] = $this->_messageTemplatesUser[self::NOT_TRANSITION_AUTO_INFO];
         return false;
     }
     if (!$auto && !$manual) {
         $this->_messages = array();
         $this->_messages[self::NOT_TRANSITION_AVAILABLE] = $this->_messageTemplatesUser[self::NOT_TRANSITION_AVAILABLE];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!$data instanceof ExpenseControlLimitModel) {
         throw new InvalidArgumentException("Expected " . get_class(ExpenseControlLimitModel));
     }
     parent::isValid($data, $context, $removeNotPresentFields);
 }
 public function __construct($options = null)
 {
     $this->_messageTemplates[self::TOO_MUCH_DEPTH] = 'Too many nested configurations';
     $this->_spec = array('breakChainOnFailure' => true, 'validators' => array('ValidateOne' => array('breakChainOnFailure' => true, 'prefixPath' => array("\\Core\\Model\\Validate\\" => APPLICATION_PATH . "/modules/core/models/Validate/"), 'validators' => array('IsBoolean' => array('breakChainOnFailure' => true), 'Int' => array('breakChainOnFailure' => true), 'StringLength' => array('breakChainOnFailure' => true, 'max' => 2047), 'Config\\ArrayConfigValidate' => array('breakChainOnFailure' => true, 'acceptArrayAsModel' => true), 'Config\\StructConfigValidate' => array('breakChainOnFailure' => true, 'acceptArrayAsModel' => true)))));
     $this->_keysSpec = array('validators' => array('StringLength' => array('breakChainOnFailure' => true, 'min' => 1, 'max' => 31), 'Regex' => array('breakChainOnFailure' => true, 'pattern' => ' /^[a-zA-Z0-9\\-\\_]+$/')));
     parent::__construct($options);
 }
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if ($this->_ignoreDeleted && $this->_isDeleted($data)) {
         return true;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof ServiceTariffModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_SERVICE_TARIFF] = $this->_messageTemplatesUser[self::NOT_SERVICE_TARIFF];
         return false;
     }
     if (!parent::isValid($data, $context, $removeNotPresentFields)) {
         return false;
     }
     if (!$data instanceof ServiceTariffModel) {
         $data = new ServiceTariffModel($data);
     }
     if ($data->getN3() !== null && $data->getN2() === null || $data->getN4() !== null && $data->getN2() === null || $data->getN5() !== null && $data->getN4() === null) {
         $this->_messages = array();
         $this->_messages[self::INVALID_SERVICE_TARIFF] = $this->_messageTemplatesUser[self::INVALID_SERVICE_TARIFF];
         return false;
     }
     if ($data->getN3() === null && $data->getN2() !== null && $data->getN4() !== null && $data->getT2Q() === $data->getT4Q()) {
         $this->_messages = array();
         $this->_messages[self::INVALID_SAME_SLOPE_IN_ROW] = $this->_messageTemplatesUser[self::INVALID_SAME_SLOPE_IN_ROW];
         return false;
     }
     return true;
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof AlarmRuleModel || is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_ALARM_RULE] = $this->_messageAlarmRule[self::NOT_ALARM_RULE];
         return false;
     }
     if (!parent::isValid($data, $context, $removeNotPresentFields)) {
         return false;
     }
     if (!$data instanceof AlarmRuleModel) {
         $data = new AlarmRuleModel($data);
     }
     switch ($data->universeType) {
         case AlarmRuleModel::UNIVERSE_SUBSCRIPTIONS_OF_COMMERCIAL_GROUP:
         case AlarmRuleModel::UNIVERSE_COMMERCIAL_GROUP:
             $validator = new \App_Validate_Ericsson_CommercialGroupExistsById();
             break;
         case AlarmRuleModel::UNIVERSE_BILLING_ACCOUNT:
             $validator = new \App_Validate_Ericsson_BillingAccountExistsById(array('organizationIdField' => 'customerId'));
             break;
         case AlarmRuleModel::UNIVERSE_CUSTOMER:
             $validator = new \App_Validate_Ericsson_OrganizationExistsById();
             $validator->setOrganizationType(OrgCustomerModel::ORG_TYPE);
             break;
         case AlarmRuleModel::UNIVERSE_SUBSCRIPTIONS_OF_SUPERVISION_GROUP:
             $validator = new \App_Validate_Amplia_SupervisionGroupExistsByName();
             break;
     }
     if (!$validator->isValid($data->universeId, $data->exportData())) {
         $this->_messages['universeId'] = $validator->getMessages();
         return false;
     }
     return true;
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof TariffPlanServicesModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_TARIFF_PLAN_SERVICES] = $this->_messageTemplatesUser[self::NOT_TARIFF_PLAN_SERVICES];
         return false;
     }
     if (!parent::isValid($data, $context, $removeNotPresentFields)) {
         return false;
     }
     if (!$data instanceof TariffPlanServicesModel) {
         $data = new TariffPlanServicesModel($data);
     }
     /*
      * GLOBALPORTAL-97959
      */
     $ignoreDeleted = $data->id && $data->published == ServicePackModel::STATUS_PUBLISHED;
     $tariffsData = $data->getData();
     $tariffsData[] = $data->getDefaultData();
     $validatorData = new TariffPlan\Services\Complex\DataTariffValidate(array('ignoreDeleted' => $ignoreDeleted));
     $tariffsVoice = $data->getOrigVoice();
     $tariffsVoice[] = $data->getDefaultOrigVoice();
     $validatorVoice = new TariffPlan\Services\Complex\VoiceTariffValidate(array('ignoreDeleted' => $ignoreDeleted));
     $tariffsTerm = $data->getTermVoice();
     $tariffsTerm[] = $data->getDefaultTermVoice();
     $validatorTerm = new TariffPlan\Services\Complex\VoiceTariffValidate(array('ignoreDeleted' => $ignoreDeleted));
     $tariffsSms = $data->getSms();
     $tariffsSms[] = $data->getDefaultSms();
     $validatorSms = new TariffPlan\Services\Complex\SmsTariffValidate(array('ignoreDeleted' => $ignoreDeleted));
     if (!$this->_correctNumberOfComplexTariffs($tariffsData, $validatorData, 'data') || !$this->_correctNumberOfComplexTariffs($tariffsVoice, $validatorVoice, 'originated voice') || !$this->_correctNumberOfComplexTariffs($tariffsTerm, $validatorTerm, 'terminated voice') || !$this->_correctNumberOfComplexTariffs($tariffsSms, $validatorSms, 'sms')) {
         return false;
     }
     return true;
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof \Application\Proto\AlarmRule\Rule\AlarmInfo || is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_ALARM_INFO] = $this->_messageRule[self::NOT_ALARM_INFO];
         return false;
     }
     if (isset($context['condition'])) {
         if ($context['condition'] !== AlarmRuleCondition::CONDITION_LIFE_CYCLE_STATUS_CHANGE) {
             $this->_spec['validators']['timeout']['Empty'] = array('breakChainOnFailure' => true);
         } else {
             if (isset($this->_spec['validators']['timeout']['Empty'])) {
                 unset($this->_spec['validators']['timeout']['Empty']);
             }
         }
         if (!in_array($context['condition'], array(AlarmRuleCondition::CONDITION_SUP_GPRS_CONN, AlarmRuleCondition::CONDITION_SUP_GPRS_DISCONN, AlarmRuleCondition::CONDITION_SUP_IP_CONN, AlarmRuleCondition::CONDITION_SUP_IP_DISCONN))) {
             $this->_spec['validators']['delay']['Empty'] = array('breakChainOnFailure' => true);
         } else {
             if (isset($this->_spec['validators']['delay']['Empty'])) {
                 unset($this->_spec['validators']['delay']['Empty']);
             }
         }
         if ($context['condition'] !== AlarmRuleCondition::CONDITION_SUP_LOC_CHANGE) {
             $this->_spec['validators']['threshold']['Empty'] = array('breakChainOnFailure' => true);
         } else {
             if (isset($this->_spec['validators']['threshold']['Empty'])) {
                 unset($this->_spec['validators']['threshold']['Empty']);
             }
         }
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof TimeAndConsumptionVoucherModel || is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_TIME_AND_CONSUMPTION_VOUCHER] = $this->_messageTimeAndConsumptionVoucher[self::NOT_TIME_AND_CONSUMPTION_VOUCHER];
         return false;
     }
     if (!$data instanceof TimeAndConsumptionVoucherModel) {
         $data = new TimeAndConsumptionVoucherModel($data);
     }
     $fields = array('dataTime', 'dataConsumption');
     if ($data->enabled === false && $this->_disabling === false) {
         foreach ($fields as $field) {
             if (isset($this->_spec['validators'][$field]['NotEmptyIfField'])) {
                 unset($this->_spec['validators'][$field]['NotEmptyIfField']);
             }
             $this->_spec['validators'][$field]['Identical'] = array('breakChainOnFailure' => true, 'token' => 0, 'messages' => array(\Zend_Validate_Identical::NOT_SAME => 'If "enabled" is false, "dataTime" and "dataConsumption" fields must be 0'));
             $this->_disabling = true;
         }
     } else {
         if ($this->_disabling) {
             $this->_setSpec();
         }
     }
     //TODO Check validations for each type
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 public function __construct($options = null)
 {
     $discounts = array('general', 'baSubscriptions', 'customerSubscriptions', 'expense', 'consumptionVoice', 'consumptionSms', 'consumptionData');
     foreach ($discounts as $discount) {
         $this->_spec['validators'][$discount] = array('Array' => array('prefixPath' => array("\\Application\\Model\\Validate\\" => APPLICATION_PATH . "/modules/default/models/Validate/"), 'breakChainOnFailure' => true, 'validators' => array('DiscountValidate' => array('breakChainOnFailure' => true, 'acceptArrayAsModel' => true))));
     }
     parent::__construct($options);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof ZoneGroupModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_error(self::NOT_ZONE_GROUP);
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!$data instanceof \Application\Model\SupplServicesModel) {
         $this->_messages = array();
         $this->_messages[self::NOT_SUPPLSERVICES] = $this->_messageTemplatesSupplServices[self::NOT_SUPPLSERVICES];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 public function __construct($options = null)
 {
     $this->_messageTemplates[self::TOO_MUCH_DEPTH] = 'Too many nested configurations';
     $this->_messageTemplates[self::INVALID_ITEM_TYPE] = 'Unrecognized type of first element';
     $this->_messageTemplates[self::NOT_HOMOGENUOUS_ARRAY] = 'Every item must be same type';
     $this->_spec = array();
     $this->_keysSpec = array('validators' => array('Int' => array('breakChainOnFailure' => true)));
     parent::__construct($options);
 }
Example #15
0
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!$data instanceof ServicePack\Discount && (!$this->_acceptArrayAsModel || !is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_SERVICE_PACK_DISCOUNT] = $this->_messageTemplatesDiscount[self::NOT_SERVICE_PACK_DISCOUNT];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof VoiceSmsRestrictionModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_VOICE_SMS_RESTRICTION] = $this->_messageTemplatesUser[self::NOT_VOICE_SMS_RESTRICTION];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!$data instanceof \Download\Model\DownloadTokenModel) {
         $this->_messages = array();
         $this->_messages[self::NOT_DOWNLOAD_TOKEN] = $this->_messageTemplatesUser[self::NOT_DOWNLOAD_TOKEN];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof \Application\Model\AlarmRule\Notification || is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_NOTIFICATION] = $this->_messageRule[self::NOT_NOTIFICATION];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof ServiceTariffModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_messages = array(self::NOT_SERVICE_TARIFF => $this->_messageTemplatesUser[self::NOT_SERVICE_TARIFF]);
         return false;
     }
     $isValid = parent::isValid($data, $context, $removeNotPresentFields);
     return $isValid ? $this->_validateRange($data) : false;
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!$data instanceof SupervisionGroupModel) {
         $this->_messages = array();
         $this->_messages[self::NOT_SUPERVISION_GROUP] = $this->_messageTemplatesServicePack[self::NOT_SUPERVISION_GROUP];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof BillingAccount || is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_BILLING_ACCOUNT] = $this->_messageTemplatesAddress[self::NOT_BILLING_ACCOUNT];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof Attendance || is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_ATTENDANCE] = $this->_messageAttendance[self::NOT_ATTENDANCE];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     $this->_messages = array();
     if (!$data instanceof SimModel) {
         $this->_messages[self::NOT_SIM] = $this->_messageNotSim[self::NOT_SIM];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof Contact || is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_CONTACT] = $this->_messageTemplatesContact[self::NOT_CONTACT];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof StatusModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_STATUS] = $this->_messageTemplatesUser[self::NOT_STATUS];
         return false;
     }
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof TariffPlanLifeCycleModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_TARIFF_PLAN_LIFECYCLE] = $this->_messageTemplatesUser[self::NOT_TARIFF_PLAN_LIFECYCLE];
         return false;
     }
     //TODO Check validations for each type
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof DiscountThreshold || is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_DISCOUNTTHRESHOLD] = $this->_messageDiscountThresholds[self::NOT_DISCOUNTTHRESHOLD];
         return false;
     }
     //TODO Check validations for each type
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof Tax || is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_TAX] = $this->_messageTaxsUser[self::NOT_TAX];
         return false;
     }
     //TODO Check validations for each type
     return parent::isValid($data, $context, $removeNotPresentFields);
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!($data instanceof RestrictionModel || $this->_acceptArrayAsModel && is_array($data))) {
         $this->_messages = array();
         $this->_messages[self::NOT_RESTRICTIONS] = $this->_messageTemplatesUser[self::NOT_RESTRICTIONS];
         return false;
     }
     if (!parent::isValid($data, $context, $removeNotPresentFields)) {
         return false;
     }
     if (!$data instanceof RestrictionModel) {
         $data = new RestrictionModel($data);
     }
     $contracts = ContractService::getInstance()->getContractsByServiceType('csrm')->getItems();
     if (!empty($contracts)) {
         $validator = new \Zend_Validate_NotEmpty();
     } else {
         $validator = new \App_Validate_Empty();
     }
     if (!$validator->isValid($data->steering)) {
         $this->_messages['steering'] = $validator->getMessages();
         return false;
     }
     // If Voice HOME = SMS HOME, roaming is linked
     if ($data->getVoice() && $data->getVoice()->getMo() && $data->getSms() && $data->getSms()->getMo() && $data->getVoice()->getMo()->getHome() === $data->getSms()->getMo()->getHome() && $data->getVoice()->getMo()->getRoaming() !== $data->getSms()->getMo()->getRoaming()) {
         $this->_messages = array();
         $this->_messages[self::NOT_SYNC_VOICE_SMS_ROAMING] = $this->_messageTemplatesUser[self::NOT_SYNC_VOICE_SMS_ROAMING];
         return false;
     }
     //      https://jira.tid.es/browse/GLOBALPORTAL-115352
     //         if ($data->getSms() && $data->getSms()->getMo() &&
     //             // If HOME is disabled and Roaming Enabled
     //             (($data->getSms()->getMo()->getHome() &&  !$data->getSms()->getMo()->getRoaming()) ||
     //                 // If HOME is enabled and Roaming !== International
     //                 (isset($data->getSms()->getMo()->roaming) &&
     //                     $data->getSms()->getMo()->getRoaming() !== $data->getSms()->getMo()->getInternational()))) {
     //             $this->_messages = array();
     //             $this->_messages[self::NOT_ROAMING_INTERNATIONAL_SAME_VALUE] =
     //                 $this->_messageTemplatesUser[self::NOT_ROAMING_INTERNATIONAL_SAME_VALUE];
     //             return false;
     //         }
     // Validate leading/commercial OB
     $org = \App::getOrgUserLogged();
     $orgProvider = OrgService::getInstance()->getParentByType($org->id, OrgServiceProviderModel::ORG_TYPE);
     if ($orgProvider && \Application\Service\OrgService::getInstance()->isCommercial($orgProvider)) {
         $validator = new RestrictionsCommercialValidate();
         if (!$validator->isValid($data, $context, $removeNotPresentFields)) {
             $this->_messages = $validator->getMessages();
             return false;
         }
     }
     return true;
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     $parent_is_valid = parent::isValid($data, $context, $removeNotPresentFields);
     if (!$parent_is_valid) {
         return $parent_is_valid;
     }
     if (!($data instanceof SmsMsisdnModel || is_array($data))) {
         $this->_error(self::NO_SMS_MSISDN);
         return false;
     }
     return $parent_is_valid;
 }