/**
  * Validate element value
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!parent::isValid($data, $context, $removeNotPresentFields)) {
         return false;
     }
     if ($context && is_array($context)) {
         // Check total sum
         $sum = 0;
         $list = array('limitVoice', 'limitSms', 'limitData');
         //extract from the context the list of desired parameters
         $limitDataParams = array_intersect_key($context, array_flip($list));
         if ($this->_allLimitsEnabled($limitDataParams) && $this->_totalEnabled($data)) {
             $limitDataSum = $this->_getLimitSum($data, $limitDataParams);
             $totalLimit = $this->_getValue($data);
             $maxLimitData = $this->_getMaxLimit($limitDataParams);
             //TODO change message
             if ($totalLimit > $limitDataSum) {
                 $this->_messages[self::TOTAL_MORE_THAN_ALLSUM] = $this->_messageTemplatesUser[self::TOTAL_MORE_THAN_ALLSUM];
                 return false;
             }
             if ($maxLimitData > $totalLimit) {
                 $this->_messages[self::TOTAL_LESS_THAN_MAX] = $this->_messageTemplatesUser[self::TOTAL_LESS_THAN_MAX];
                 return false;
             }
         }
     }
     return true;
 }
 /**
  * Validate element value
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!parent::isValid($data, $context, $removeNotPresentFields)) {
         return false;
     }
     if ($context && is_array($context)) {
         // Check total sum
         $sum = 0;
         $list = array('limitVoice', 'limitSms', 'limitData');
         foreach ($list as $field) {
             if ($this->_getEnabled($data) && $this->_getValue($context[$field]) > $this->_getValue($data)) {
                 $this->_messages = array();
                 $this->_messages[self::TOTAL_REACHED] = $this->_messageTemplatesUser[self::TOTAL_REACHED];
                 return false;
             }
         }
     }
     return true;
 }