Defines the validator using the methods on Cake\Validation\Validator or
loads a pre-defined validator from a concrete class.
@param \Cake\Validation\Validator $validator Validator instance
@return \MeCms\Validation\AppValidator
13736
protected function _buildValidator(Validator $validator)
    {
        $validator = new AppValidator;

        //Filename
        $validator->add('filename', 'extension', [
            'message' => __d('me_cms', 'Valid extensions: {0}', 'sql, sql.gz, sql.bz2'),
            'rule' => function ($value) {
                return (bool)preg_match('/[^\.]\.sql(\.(bz2|gz))?$/', $value);
            },
        ])->requirePresence('filename');

        return $validator;
    }
1042024
protected function _buildValidator(Validator $validator)
    {
        $validator = new AppValidator;

        //First name
        $validator->requirePresence('first_name');

        //Last name
        $validator->requirePresence('last_name');

        //Email
        $validator->requirePresence('email');

        //Message
        $validator->add('message', [
            'lengthBetween' => [
                'message' => __d('me_cms', 'Must be between {0} and {1} chars', 10, 1000),
                'rule' => ['lengthBetween', 10, 1000],
            ],
        ])->requirePresence('message');

        return $validator;
    }
598383
public function validationDefault(Validator $validator)
    {
        $validator
            ->uuid('id')
            ->allowEmpty('id', 'create');

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

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

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

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

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

        $validator
            ->uuid('created_by')
            ->notEmpty('created_by');

        $validator
            ->uuid('modified_by')
            ->notEmpty('modified_by');

        return $validator;
    }
1275408
public function validationDefault(Validator $validator)
    {
        $validator
            ->uuid('id')
            ->allowEmpty('id', 'create');

        $validator
            ->allowEmpty('source');

        $validator
            ->requirePresence('title', 'create')
            ->allowEmpty('title');

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

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

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

        $validator
            ->time('duration')
            ->allowEmpty('duration');

        return $validator;
    }
739770
protected function removeValidator(Validator $validator) : Component
    {
        $hash = spl_object_hash($validator);
        unset($this->validators[$hash]);

        return $this;
    }
91035
public function validationDefault(Validator $validator): \Cake\Validation\Validator
    {
        $validator
            ->add('id', 'valid', ['rule' => 'uuid'])
            ->allowEmpty('id', 'create');

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

        return $validator;
    }
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;
    }
1138976
public function setValidator($validator)
    {
        $this->clearCache();
        $this->validators = [];
        $this->addValidator($validator);

        return $this;
    }
675659
public function validator()
    {
        return Validator::make(
            $this->params, $this->rules(),
            $this->messages(), $this->attributes()
        );
    }
314791
protected function hasValidator(Validator $validator) : bool
    {
        $hash = spl_object_hash($validator);

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

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

        return $this;
    }
583980
public function addValidator(ValidatorInterface $validator)
    {
        $formDefinition = $this->getRootForm();
        $formDefinition->getProcessingRule($this->getIdentifier())->addValidator($validator);
    }
548953
public function validationDefault(Validator $validator)
    {
        $validator
            ->uuid('id')
            ->allowEmpty('id', 'create');

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

        $validator
            ->allowEmpty('color');

        $validator
            ->allowEmpty('icon');

        $validator
            ->allowEmpty('source');

        return $validator;
    }
233143
public function validationPasswordReset(Validator $validator) {
		return $this->validateOldPassword($validator)
			->validatePassword($validator)
			->validateConfirmPassword($validator);
	}
57923
public function validationDefault(Validator $validator)
    {
        $validator
            ->uuid('id')
            ->allowEmpty('id', 'create');

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

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

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

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

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

        return $validator;
    }
322219
public function validate(Validator $validator = null)
    {
        if (null === $validator) {
            $validator = new Validator(new ClassMetadataFactory(new StaticMethodLoader()), new ConstraintValidatorFactory(), new DefaultTranslator());
        }

        $failureMap = new ConstraintViolationList();

        if (!$this->alreadyInValidation) {
            $this->alreadyInValidation = true;
            $retval = null;


            $retval = $validator->validate($this);
            if (count($retval) > 0) {
                $failureMap->addAll($retval);
            }

            if (null !== $this->collAttributeAttributeTypes) {
                foreach ($this->collAttributeAttributeTypes as $referrerFK) {
                    if (method_exists($referrerFK, 'validate')) {
                        if (!$referrerFK->validate($validator)) {
                            $failureMap->addAll($referrerFK->getValidationFailures());
                        }
                    }
                }
            }
            if (null !== $this->collAttributeTypeI18ns) {
                foreach ($this->collAttributeTypeI18ns as $referrerFK) {
                    if (method_exists($referrerFK, 'validate')) {
                        if (!$referrerFK->validate($validator)) {
                            $failureMap->addAll($referrerFK->getValidationFailures());
                        }
                    }
                }
            }

            $this->alreadyInValidation = false;
        }

        $this->validationFailures = $failureMap;

        return (Boolean) (!(count($this->validationFailures) > 0));

    }
596813
public function validationDefault(Validator $validator) {
		$validator
			->integer('id')
			->allowEmpty('id', 'create');

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

		$validator
			->allowEmpty('formatted_address');

		$validator
			->allowEmpty('country');

		$validator
			->decimal('lat')
			->allowEmpty('lat');

		$validator
			->decimal('lng')
			->allowEmpty('lng');

		$validator
			->allowEmpty('data');

		return $validator;
	}