Merge validation messages from input validators.

@param \Illuminate\Validation\Validator[] $validators

@return MessageBag
770658
protected function mergeValidationMessages($validators)
    {
        $messageBag = new MessageBag();

        foreach ($validators as $validator) {
            $messageBag = $messageBag->merge($validator->messages());
        }

        return $messageBag;
    }
739108
public function addValidator(Validator $validator) : Component
    {
        $hash = spl_object_hash($validator);
        $this->validators[$hash] = $validator;

        return $this;
    }
641350
public function extend($validator)
	{
		$validator = is_array($validator) ? $validator : [$validator];

		$this->validators = array_merge($this->validators, $validator);

		return $this;
	}
1001278
private function validate( $values ) {

		$is_valid = TRUE;

		foreach ( $values as $key => $value ) {

			if ( ! is_scalar( $value ) ) {
				continue;
			}

			foreach ( $this->validators as $validator ) {
				$is_valid = $validator->is_valid( $value );

				if ( ! $is_valid ) {
					$this->error_messages[ $key ] = $validator->get_error_messages();
					break;
				}
			}

			if ( ! $is_valid ) {
				break;
			}
		}

		return $is_valid;
	}
1344418
public function addFieldValidators(array $fieldValidators)
    {
        foreach ($fieldValidators as $fieldName => $validators) {
            $this->fieldValidators[$fieldName] = $validators;
        }
    }
823514
public function validationDefault(Validator $validator)
    {
        $validator
            ->uuid('id')
            ->allowEmpty('id', 'create');

        $validator
            ->requirePresence('type', 'create')
            ->notEmpty('type');

        $validator
            ->requirePresence('content', 'create')
            ->notEmpty('content');

        $validator
            ->requirePresence('name', 'create')
            ->notEmpty('name')
            ->add('name', 'unique', ['rule' => 'validateUnique', 'provider' => 'table']);

        $validator
            ->dateTime('trashed')
            ->allowEmpty('trashed');

        return $validator;
    }
1309498
public function setValidator(Validator $validator)
    {
        if ($validator) {
            $this->validator = $validator;
            $this->validator->setForm($this);
        }
        return $this;
    }
693987
public function validationDefault(Validator $validator)
    {
        $validator
            ->add('id', 'valid', ['rule' => 'numeric'])
            ->allowEmpty('id', 'create');

        $validator
            ->requirePresence('upload_id', 'create')
            ->notEmpty('upload_id');

        $validator
            ->requirePresence('original_filename', 'create')
            ->notEmpty('original_filename');

        $validator
            ->requirePresence('unique_filename', 'create')
            ->notEmpty('unique_filename');

        $validator
            ->allowEmpty('subfolder');

        $validator
            ->allowEmpty('mimetype');

        $validator
            ->add('size', 'valid', ['rule' => 'numeric'])
            ->requirePresence('size', 'create')
            ->notEmpty('size');

        $validator
            ->requirePresence('hash', 'create')
            ->notEmpty('hash');

        $validator
            ->add('upload_complete', 'valid', ['rule' => 'boolean'])
            ->requirePresence('upload_complete', 'create')
            ->notEmpty('upload_complete');

        $validator
            ->allowEmpty('label');

        $validator
            ->add('created_by', 'valid', ['rule' => 'numeric'])
            ->requirePresence('created_by', 'create')
            ->notEmpty('created_by');

        $validator
            ->add('modified_by', 'valid', ['rule' => 'numeric'])
            ->allowEmpty('modified_by');

        return $validator;
    }
43575
public T validator(MessageValidator<? extends ValidationContext> ... validators) {
        Stream.of(validators).forEach(getAction()::addValidator);
        return self;
    }
664225
public static function hydrateCollection(array $validators)
    {
        $hydrated = [];

        foreach ($validators as $validator) {
            $hydrated[] = self::hydrate($validator);
        }

        return $hydrated;
    }
1248340
protected function _addValidators(Input &$input, array $validators)
    {
        foreach($validators as $validator => $message) {
            $input->getValidatorChain()
                ->add(StaticValidator::create($validator, $message));
        }
    }
946607
public function addValidators(array $validators)
    {
        foreach ($validators as $validator) {
            if ($validator === null) {
                continue;
            }

            $this->addValidator($validator);
        }

        return $this;
    }
617542
public function withValidator(string $name, ValidatorInterface $validator): Form
    {
        if (! isset($this->validators[$name])) {
            $this->validators[$name] = [];
        }

        $this->validators[$name][] = $validator;

        return $this;
    }
160413
protected function addExtensions(Validator $validator)
    {
        $validator->addExtensions($this->extensions);

        // Next, we will add the implicit extensions, which are similar to the required
        // and accepted rule in that they are run even if the attributes is not in a
        // array of data that is given to a validator instances via instantiation.
        $implicit = $this->implicitExtensions;

        $validator->addImplicitExtensions($implicit);

        $validator->addReplacers($this->replacers);

        $validator->setFallbackMessages($this->fallbackMessages);
    }
1266750
public function addValidation(Validator $validator) {
		$fields = (array)$this->getConfig('dummyField');
		foreach ($fields as $field) {
			$validator->requirePresence($field);
			$validator->allowEmpty($field);
			$validator->add($field, [
				$field => [
					'rule' => function ($value, $context) {
						return $value === '';
					},
					'last' => true
				],
			]);
		}
	}
417960
public function validationDefault(Validator $validator)
    {
        $validator
            ->add('id', 'valid', ['rule' => 'numeric'])
            ->allowEmpty('id', 'create');

        $validator
            ->add('email', 'valid', ['rule' => 'email'])
            ->notEmpty('email');

        $validator
            ->notEmpty('password');

        $validator
            ->allowEmpty('new_password');


        $validator
            ->allowEmpty('confirm_password');

        $validator
            ->add('new_password', 'custom', [
                'rule' => function ($value, $context) {
                    if (!array_key_exists('confirm_password', $context['data'])) {
                        return false;
                    }
                    if ($value !== $context['data']['confirm_password']) {
                        return false;
                    }
                    return true;
                },
                'message' => __d('CakeAdmin', 'Passwords are not equal.')]);

        $validator
            ->add('confirm_password', 'custom', ['rule' => function ($value, $context) {
                if (!array_key_exists('new_password', $context['data'])) {
                    return false;
                }
                if ($value !== $context['data']['new_password']) {
                    return false;
                }
                return true;
            },
                'message' => __d('CakeAdmin', 'Passwords are not equal.')]);

        return $validator;
    }
1340806
public function addValidator(Validator\ValidatorInterface $validator) {
        $this->validators[get_class($validator)] = $validator;
        
        return $this;
    }