/**
  * @return bool
  * @desc Check whether the field(s) are valid
  */
 function IsValid()
 {
     // Cache validation so that multiple calls to IsValid don't process again
     if (isset($this->b_valid)) {
         return $this->b_valid;
     }
     if (is_array($this->a_keys) and is_array($this->a_data)) {
         if ($this->i_mode == ValidatorMode::SingleField()) {
             if (!isset($this->a_data[$this->a_keys[0]])) {
                 $this->b_valid = $this->b_valid_if_not_found;
             } else {
                 $this->b_valid = $this->Test($this->a_data[$this->a_keys[0]], $this->a_keys);
             }
         } elseif ($this->i_mode == ValidatorMode::AnyField()) {
             $b_valid = false;
             foreach ($this->a_keys as $s_key) {
                 $b_valid = $b_valid || (isset($this->a_data[$s_key]) and $this->Test($this->a_data[$s_key], $this->a_keys));
             }
             $this->b_valid = $b_valid;
         } elseif ($this->i_mode == ValidatorMode::AllFields()) {
             $b_valid = true;
             foreach ($this->a_keys as $s_key) {
                 $b_valid = ($b_valid and (isset($this->a_data[$s_key]) and $this->Test($this->a_data[$s_key], $this->a_keys)));
             }
             $this->b_valid = $b_valid;
         } elseif ($this->i_mode == ValidatorMode::AllOrNothing()) {
             $b_valid = true;
             $b_expected = (isset($this->a_data[$this->a_keys[0]]) and $this->Test($this->a_data[$this->a_keys[0]], $this->a_keys));
             $i_fields = count($this->a_keys);
             if ($i_fields > 1) {
                 for ($i = 1; $i < $i_fields; $i++) {
                     if ((isset($this->a_data[$this->a_keys[$i]]) and $this->Test($this->a_data[$this->a_keys[$i]], $this->a_keys)) != $b_expected) {
                         $b_valid = false;
                     }
                 }
             }
             $this->b_valid = $b_valid;
         } elseif ($this->i_mode == ValidatorMode::MultiField()) {
             $this->b_valid = $this->Test($this->a_data, $this->a_keys);
         }
     } else {
         $this->b_valid = false;
     }
     return $this->b_valid;
 }
 /**
  * @return CompareValidator
  * @param array $a_keys
  * @param string $s_message
  * @desc Test whether given fields are the same
  */
 function CompareValidator($a_keys, $s_message)
 {
     parent::DataValidator($a_keys, $s_message, ValidatorMode::MultiField());
 }
 /**
  * Creates a new TeamNameValidator
  * @param string[] $a_keys
  * @param string $message
  * @return void
  */
 public function __construct($a_keys, $message)
 {
     parent::DataValidator($a_keys, $message, ValidatorMode::MultiField());
 }
 /**
  * @return RequiresOtherFieldsValidator
  * @param array Validated field followed by other required fields $a_keys
  * @param string $s_message
  * @param array(array()) Acceptable values in required fields $requires_values
  * @desc If the first given field has data, require the subsequent fields
  */
 public function __construct($a_keys, $s_message, $requires_values = null)
 {
     parent::DataValidator($a_keys, $s_message, ValidatorMode::MultiField());
     $this->requires_values = is_array($requires_values) ? $requires_values : array();
 }