original_string: public function validates($data, $options = [])
      {
          $events = (array) (isset($options['events']) ? $options['events'] : null);
  
          $this->_errors = [];
          $error = $this->_error;
  
          foreach ($this->_rules as $field => $rules) {
              $values = static::values($data, explode('.', $field));
  
              foreach ($rules as $name => $rule) {
                  $rule += $options;
                  $rule['field'] = $field;
  
                  if ($events && $rule['on'] && !array_intersect($events, (array) $rule['on'])) {
                      continue;
                  }
  
                  if (!$values && $rule['required']) {
                      $rule['message'] = null;
                      $this->_errors[$field][] = $error('required', $rule, $this->_meta);
                      break;
                  } else {
                      foreach ($values as $key => $value) {
                          if (empty($value) && $rule['skipEmpty']) {
                              continue;
                          }
                          if (!$this->is($name, $value, $rule + compact('data'), $params)) {
                              $this->_errors[$key][] = $error($name, $params + $rule, $this->_meta);
                          }
                      }
                  }
              }
          }
          return !$this->_errors;
      }
code: public function validates($data, $options = [])
      {
          $events = (array) (isset($options['events']) ? $options['events'] : null);
  
          $this->_errors = [];
          $error = $this->_error;
  
          foreach ($this->_rules as $field => $rules) {
              $values = static::values($data, explode('.', $field));
  
              foreach ($rules as $name => $rule) {
                  $rule += $options;
                  $rule['field'] = $field;
  
                  if ($events && $rule['on'] && !array_intersect($events, (array) $rule['on'])) {
                      continue;
                  }
  
                  if (!$values && $rule['required']) {
                      $rule['message'] = null;
                      $this->_errors[$field][] = $error('required', $rule, $this->_meta);
                      break;
                  } else {
                      foreach ($values as $key => $value) {
                          if (empty($value) && $rule['skipEmpty']) {
                              continue;
                          }
                          if (!$this->is($name, $value, $rule + compact('data'), $params)) {
                              $this->_errors[$key][] = $error($name, $params + $rule, $this->_meta);
                          }
                      }
                  }
              }
          }
          return !$this->_errors;
      }
code_tokens: public function validates ( $ data , $ options = [ ] ) { $ events = ( array ) ( isset ( $ options [ 'events' ] ) ? $ options [ 'events' ] : null ) ; $ this -> _errors = [ ] ; $ error = $ this -> _error ; foreach ( $ this -> _rules as $ field => $ rules ) { $ values = static :: values ( $ data , explode ( '.' , $ field ) ) ; foreach ( $ rules as $ name => $ rule ) { $ rule += $ options ; $ rule [ 'field' ] = $ field ; if ( $ events && $ rule [ 'on' ] && ! array_intersect ( $ events , ( array ) $ rule [ 'on' ] ) ) { continue ; } if ( ! $ values && $ rule [ 'required' ] ) { $ rule [ 'message' ] = null ; $ this -> _errors [ $ field ] [ ] = $ error ( 'required' , $ rule , $ this -> _meta ) ; break ; } else { foreach ( $ values as $ key => $ value ) { if ( empty ( $ value ) && $ rule [ 'skipEmpty' ] ) { continue ; } if ( ! $ this -> is ( $ name , $ value , $ rule + compact ( 'data' ) , $ params ) ) { $ this -> _errors [ $ key ] [ ] = $ error ( $ name , $ params + $ rule , $ this -> _meta ) ; } } } } } return ! $ this -> _errors ; }
docstring: Validates a set of values against a specified rules list. This method may be used to validate
  any arbitrary array of data against a set of validation rules.
  
  @param array $data    An array of key/value pairs, where the values are to be checked.
  @param array $rules   An array of rules to check the values in `$values` against. Each key in
  `$rules` should match a key contained in `$values`, and each value should be a
  validation rule in one of the allowable formats. For example, if you are
  validating a data set containing a `'credit_card'` key, possible values for
  `$rules` would be as follows:
  - `['credit_card' => 'You must include a credit card number']`: This is the
  simplest form of validation rule, in which the value is simply a message to
  display if the rule fails. Using this format, all other validation settings
  inherit from the defaults, including the validation rule itself, which only
  checks to see that the corresponding key in `$values` is present and contains
  a value that is not empty. _Please note when globalizing validation messages:_
  When specifying messages, it may be preferable to use a code string (i.e.
  `'ERR_NO_TITLE'`) instead of the full text of the validation error. These code
  strings may then be translated by the appropriate tools in the templating layer.
  - `['credit_card' => ['creditCard', 'message' => 'Invalid CC #']]`:
  In the second format, the validation rule (in this case `creditCard`) and
  associated configuration are specified as an array, where the rule to use is
  the first value in the array (no key), and additional settings are specified
  as other keys in the array. Please see the list below for more information on
  allowed keys.
  - The final format allows you to apply multiple validation rules to a single
  value, and it is specified as follows:
  `['credit_card' => [
  ['not:empty', 'message' => 'You must include credit card number'],
  ['creditCard', 'message' => 'Your credit card number must be valid']
  ]];`
  @param array $options Validator-specific options.
  Each rule defined as an array can contain any of the following settings
  (in addition to the first value, which represents the rule to be used):
  - `'message'` _string_: The error message to be returned if the validation
  rule fails. See the note above regarding globalization of error messages.
  - `'required`' _boolean_: Represents whether the value is required to be
  present in `$values`. If `'required'` is set to `false`, the validation rule
  will be skipped if the corresponding key is not present. Defaults to `true`.
  - `'skipEmpty'` _boolean_: Similar to `'required'`, this setting (if `true`)
  will cause the validation rule to be skipped if the corresponding value
  is empty (an empty string or `null`). Defaults to `false`.
  - `'format'` _string_: If the validation rule has multiple format definitions
  (see the `add()` or `init()` methods), the name of the format to be used
  can be specified here. Additionally, two special values can be used:
  either `'any'`, which means that all formats will be checked and the rule
  will pass if any format passes, or `'all'`, which requires all formats to
  pass in order for the rule check to succeed.
  @return array           Returns an array containing all validation failures for data in `$values`,
  where each key matches a key in `$values`, and each value is an array of
  that element's validation errors.
docstring_tokens: Validates a set of values against a specified rules list . This method may be used to validate any arbitrary array of data against a set of validation rules .