对数组中的每个值都应用给定的验证器，并且要全部通过
`['foo.*.id', 'each', 'number']`
`['goods.*', 'each', 'string']`
@param array $values
@param array ...$args
- string|\Closure $validator
- ... args for $validator
@return bool
@throws \InvalidArgumentException
193413
public function eachValidator(array $values, ...$args): bool
    {
        if (!$validator = \array_shift($args)) {
            throw new \InvalidArgumentException('must setting a validator for \'each\' validate.');
        }

        foreach ($values as $value) {
            $passed = false;

            if (\is_object($validator) && \method_exists($validator, '__invoke')) {
                $passed = $validator($value, ...$args);
            } elseif (\is_string($validator)) {
                // special for required
                if ('required' === $validator) {
                    $passed = !Validators::isEmpty($value);

                } elseif (isset($this->_validators[$validator])) {
                    $callback = $this->_validators[$validator];
                    $passed   = $callback($value, ...$args);

                } elseif (\method_exists($this, $method = $validator . 'Validator')) {
                    $passed = $this->$method($value, ...$args);

                } elseif (\method_exists(Validators::class, $validator)) {
                    $passed = Validators::$validator($value, ...$args);

                    // it is function name
                } elseif (\function_exists($validator)) {
                    $passed = $validator($value, ...$args);
                } else {
                    throw new \InvalidArgumentException("The validator [$validator] don't exists!");
                }
            }

            if (!$passed) {
                return false;
            }
        }

        return true;
    }
1118325
public function validate($validator)
    {
        // Don't validate empty fields
        if (empty($this->value)) {
            return true;
        }

        if (!filter_var($this->value, FILTER_VALIDATE_URL)) {
            if (filter_var('http://' . $this->value, FILTER_VALIDATE_URL)) {
                $this->value = 'http://' . $this->value;
            } else {
                $validator->validationError(
                    $this->name,
                    _t(__CLASS__ . '.ValidationError', 'Please enter a valid URL including the http:// or https://'),
                    'validation'
                );
                return false;
            }
        }

        return true;
    }
1368747
protected function _addValidatorProps($validator = [])
    {
        foreach ($validator as $key => $value) {
            if (!isset($value) || empty($value)) {
                continue;
            }
            if ($key === 'rule' && is_array($value) && !is_callable($value)) {
                $this->_pass = array_slice($value, 1);
                $value = array_shift($value);
            }
            if (in_array($key, ['rule', 'on', 'message', 'last', 'provider', 'pass'])) {
                $this->{"_$key"} = $value;
            }
        }
    }
416236
public function validate($validator)
    {
        $values = $this->value;
        if (!$values) {
            return true;
        }
        if ($this->ajax) {
            return true;
        }

        $strValue = $values;
        if (is_array($strValue)) {
            $strValue = implode(',', $strValue);
        }
        $errorMessage = _t(
            'Select2Field.SOURCE_VALIDATION', "Please select a value within the list provided. %s is not a valid option", array('value' => $strValue)
        );
        $source = $this->getSourceAsArray();
        if (is_array($values)) {
            if (!array_intersect_key($source, array_flip($values))) {
                $validator->validationError(
                    $this->name, $errorMessage, "validation"
                );
                return false;
            }
        } else {
            if (!array_key_exists($this->value, $source)) {
                $validator->validationError(
                    $this->name, $errorMessage, "validation"
                );
                return false;
            }
        }
        return true;
    }
667716
public function validate($validator)
    {
        if ($this->checkHostname($this->Value())) {
            return true;
        }

        $validator->validationError(
            $this->getName(),
            _t('DomainNameField.INVALID_DOMAIN', 'Invalid domain name'),
            'validation'
        );
        return false;
    }
1230222
public function validateInteger(array $values)
    {
        if (count($values) != 1) {
            $vars = array('@field' => $this->translation->text('Condition'));
            return $this->translation->text('@field has invalid value', $vars);
        }

        $value = reset($values);

        if (strlen($value) > 10) {
            $vars = array('@max' => 10, '@field' => $this->translation->text('Value'));
            return $this->translation->text('@field must not be longer than @max characters', $vars);
        }

        if (ctype_digit($value)) {
            return true;
        }

        $vars = array('@field' => $this->translation->text('Condition'));
        return $this->translation->text('@field has invalid value', $vars);
    }
1366526
public function keys($values)
    {
        $keys = explode(',', $values);
        $model = $this->builder->getModel();
        $validator = validator([ 'values' => $keys ], [ 'values.*' => 'exists:'.$model->getTable().','.$model->getKeyName() ]);
        return $this->builder->when(!$validator->fails(), function (Builder $query) use($keys) {
            $query->whereKey($keys);
        });
    }
403737
public static function validate($value)
    {
        if (!is_array($value)) {
            return false;
        }
        if (
            isset($value['fromBlock']) &&
            QuantityValidator::validate($value['fromBlock']) === false &&
            TagValidator::validate($value['fromBlock']) === false
            ) {
            return false;
        }
        if (
            isset($value['toBlock']) &&
            QuantityValidator::validate($value['toBlock']) === false &&
            TagValidator::validate($value['toBlock']) === false
            ) {
            return false;
        }
        if (isset($value['address'])) {
            if (is_array($value['address'])) {
                foreach ($value['address'] as $address) {
                    if (AddressValidator::validate($address) === false) {
                        return false;
                    }
                }
            } elseif (AddressValidator::validate($value['address']) === false) {
                return false;
            }
        }
        if (isset($value['topics']) && is_array($value['topics'])) {
            foreach ($value['topics'] as $topic) {
                if (is_array($topic)) {
                    foreach ($topic as $v) {
                        if (isset($v) && HexValidator::validate($v) === false) {
                            return false;
                        }
                    }
                } else {
                    if (isset($topic) && HexValidator::validate($topic) === false) {
                        return false;
                    }
                }
            }
        }
        return true;
    }
75778
public function validate($validator)
    {
        $this->value = trim($this->value);

        $pattern = '^[a-z0-9!#$%&\'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&\'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$';

        // Escape delimiter characters.
        $safePattern = str_replace('/', '\\/', $pattern);

        if ($this->value && !preg_match('/' . $safePattern . '/i', $this->value)) {
            $validator->validationError(
                $this->name,
                _t('SilverStripe\\Forms\\EmailField.VALIDATION', 'Please enter an email address'),
                'validation'
            );

            return false;
        }

        return true;
    }
286939
public static function validate($value)
    {
        if (!is_array($value)) {
            return false;
        }
        if (isset($value['from']) && IdentityValidator::validate($value['from']) === false) {
            return false;
        }
        if (isset($value['to']) && IdentityValidator::validate($value['to']) === false) {
            return false;
        }
        if (!isset($value['topics']) || !is_array($value['topics'])) {
            return false;
        }
        foreach ($value['topics'] as $topic) {
            if (IdentityValidator::validate($topic) === false) {
                return false;
            }
        }
        if (!isset($value['payload'])) {
            return false;
        }
        if (HexValidator::validate($value['payload']) === false) {
            return false;
        }
        if (!isset($value['priority'])) {
            return false;
        }
        if (QuantityValidator::validate($value['priority']) === false) {
            return false;
        }
        if (!isset($value['ttl'])) {
            return false;
        }
        if (isset($value['ttl']) && QuantityValidator::validate($value['ttl']) === false) {
            return false;
        }
        return true;
    }
63540
protected function callValidator($validator)
    {
        if (is_callable($validator)) {
            try {
                call_user_func_array($validator, array($this->value));
            } catch (\Exception $ex) {
                $this->error = $ex->getMessage();
                return false;
            }
        }
    }
1200189
public function validate(array $values, array &$errorsList): bool
    {
        $hasErrors = false;
        foreach ($this->data as $item) {
            $type = $item[0];
            $errorMessage = $item[1];
            $elementName = $item[2];
            $value = isset($values[$elementName]) ? (string) $values[$elementName] : '';
            $hasError = false;
            if ($type === 'required') {
                if (strlen($value) === 0) {
                    $hasError = true;
                }
            } elseif ($type === 'minLength') {
                if (strlen($value) < $item[3]) {
                    $hasError = true;
                }
            } elseif ($type === 'maxLength') {
                if (strlen($value) > $item[3]) {
                    $hasError = true;
                }
            } elseif ($type === 'email') {
                if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                    $hasError = true;
                }
            } elseif ($type === 'regExp') {
                if (!filter_var($value, FILTER_VALIDATE_REGEXP, ['options' => ['regexp' => $item[3]]])) {
                    $hasError = true;
                }
            }
            if ($hasError) {
                $errorsList[] = [
                    'elementName' => $elementName,
                    'errorMessage' => $errorMessage
                ];
                $hasErrors = true;
            }
        }
        return !$hasErrors;
    }
21154
public function validate($validator)
    {
        // Validate currency
        $currencies = $this->getAllowedCurrencies();
        $currency = $this->fieldCurrency->dataValue();
        if ($currency && $currencies && !in_array($currency, $currencies)) {
            $validator->validationError(
                $this->getName(),
                _t(
                    __CLASS__ . '.INVALID_CURRENCY',
                    'Currency {currency} is not in the list of allowed currencies',
                    ['currency' => $currency]
                )
            );
            return false;
        }

        // Field-specific validation
        return $this->fieldAmount->validate($validator) && $this->fieldCurrency->validate($validator);
    }
1364136
public function validate($validator)
    {
        // Don't validate empty fields
        $this->value = trim($this->value);

        if (empty($this->value)) {
            return true;
        }

        $phone = PhoneNumber::create()->setValue($this->value);

        if (!$phone->Link()) {
            $validator->validationError(
                $this->name,
                _t(__CLASS__ . '.ValidationError', 'Please enter a valid phone number'),
                'validation'
            );
            return false;
        }

        return true;
    }
591107
public function remove($validator = ''): Chain
    {
        if (!\is_string($validator)) {
            throw new InvalidArgumentException('Validator name must be a string');
        }
        if (isset($this->chain[$validator])) {
            unset($this->chain[$validator]);
        }
        return $this;
    }
703573
public function validationDefault(Validator $validator) {
		if (!empty($this->validate)) {
			foreach ($this->validate as $field => $rules) {
				if (is_int($field)) {
					$field = $rules;
					$rules = [];
				}
				if (!$rules) {
					continue;

				}
				$rules = (array)$rules;

				foreach ($rules as $key => $rule) {
					if (is_string($rule)) {
						$ruleArray = ['rule' => $rule];
						$rules[$rule] = $ruleArray;
						unset($rules[$key]);
						$key = $rule;
						$rule = $ruleArray;
					}

					if (isset($rule['required'])) {
						$validator->requirePresence($field, $rule['required']);
						unset($rules[$key]['required']);
					}
					if (isset($rule['allowEmpty'])) {
						$validator->allowEmpty($field, $rule['allowEmpty']);
						unset($rules[$key]['allowEmpty']);
					}
					if (isset($rule['message'])) {
						if (is_array($rule['message'])) {
							$name = array_shift($rule['message']);
							//$args = array_slice($rule['message'], 1);
							$args = $this->_translateArgs($rule['message']);
							$message = __d($this->validationDomain, $name, $args);
						} else {
							$message = __d($this->validationDomain, $rule['message']);
						}
						$rules[$key]['message'] = $message;
					}

					if (!empty($rules[$key]['rule']) && ($rules[$key]['rule'] === 'notEmpty' || $rules[$key]['rule'] === ['notEmpty'])) {
						$rules[$key]['rule'] = 'notBlank';
					}

					if (!empty($rules[$key]['rule']) && ($rules[$key]['rule'] === 'isUnique' || $rules[$key]['rule'] === ['isUnique'])) {
						$rules[$key]['rule'] = 'validateUnique';
						$rules[$key]['provider'] = 'table';
					}
				}

				$validator->add($field, $rules);
			}
		}

		return $validator;
	}
190087
public function bind($values, $replaceNulls = false)
    {
        if ($values === null) {
            return $this;
        }

        // Check properties type.
        if (!is_array($values) && !is_object($values)) {
            throw new \InvalidArgumentException(sprintf('Please bind array or object, %s given.', gettype($values)));
        }

        // If is Traversable, get iterator.
        if ($values instanceof \Traversable) {
            $values = iterator_to_array($values);
        } elseif (is_object($values)) {
            // If is object, convert it to array
            $values = get_object_vars($values);
        }

        // Bind the properties.
        foreach ($values as $field => $value) {
            // Check if the value is null and should be bound.
            if ($value === null && !$replaceNulls) {
                continue;
            }

            // Set the property.
            $this->offsetSet($field, $value);
        }

        return $this;
    }