Default validation rules.

@param Validator $validator The validator to customize.
@return Validator
185890
public function validationDefault(Validator $validator)
    {
        return $validator
            ->notEmpty('name', __d('wasabi_core', 'Please enter the name of the language.'))
            ->notEmpty('iso2', __d('wasabi_core', 'Please enter the ISO 639-1 code of the language (e.g. "en").'))
            ->add('iso2', 'lengthBetween', [
                'rule' => ['lengthBetween', 2, 2],
                'message' => __d('wasabi_core', 'The ISO 639-1 code must consist of exactly 2 characters.')
            ])
            ->notEmpty('iso3', __d('wasabi_core', 'Please enter the ISO 639-2/T code of the language (e.g. "eng").'))
            ->add('iso3', 'lengthBetween', [
                'rule' => ['lengthBetween', 3, 3],
                'message' => __d('wasabi_core', 'The ISO 639-2/T code must consist of exactly 3 characters.')
            ])
            ->notEmpty('lang', __d('wasabi_core', 'Please enter the HTML lang code of the language (e.g. "en_US").'))
            ->add('lang', 'lengthBetween', [
                'rule' => ['lengthBetween', 2, 5],
                'message' => __d('wasabi_core', 'The HTML lang code must consist of 2 to 5 characters.')
            ]);
    }
731088
public static function populateValidator(Validator $validator)
	{
		if (static::$provider === null)
		{
			static::setProvider(new FromArray(true, 'validation'));
		}

		return static::$provider->populateValidator($validator);
	}
675659
public function validator()
    {
        return Validator::make(
            $this->params, $this->rules(),
            $this->messages(), $this->attributes()
        );
    }
634905
public function validationDefault(Validator $validator)
    {
        $validator
            ->uuid('id')
            ->allowEmpty('id', 'create');

        $validator
            ->allowEmpty('source');

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

        return $validator;
    }
1092642
public function addValidator(Validator $validator) : ValidationCheckerInterface
    {
        $this->validated = false;
        $validator->setValidationSet($this);
        array_push($this->validators, $validator);
        return $this;
    }
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;
    }
1238921
public function validationRequestPassword(Validator $validator) {
		$validator = $this->_table->validationDefault($validator);
		$validator->remove($this->_field('email'), 'unique');

		return $validator;
	}
314791
protected function hasValidator(Validator $validator) : bool
    {
        $hash = spl_object_hash($validator);

        return isset($this->validators[$hash]);
    }
508574
public function validationDefault(Validator $validator)
    {
        return $validator
            ->notEmpty(
                'instance_name',
                __d('wasabi_core', 'Please enter a name for your app.')
            )
            ->notEmpty(
                'instance_short_name',
                __d('wasabi_core', 'Please enter a short name for your app.')
            )
            ->notEmpty(
                'Email__email_sender',
                __d('wasabi_core', 'Please enter an email address.')
            )
            ->notEmpty(
                'Email__email_sender_name',
                __d('wasabi_core', 'Please enter a name for the email sender.')
            )
            ->add('Email__email_sender', 'validEmail', [
                'rule' => 'email',
                'message' => __d('wasabi_core', 'Please enter a valid email address.')
            ])
            ->notEmpty(
                'Login__HeartBeat__max_login_time',
                __d('wasabi_core', 'Please choose a maximum login time.')
            )
            ->add('Login__HeartBeat__max_login_time', 'valid', [
                'rule' => function ($value, $context) {
                    return in_array((int)$value, [900000, 1800000, 2700000, 3600000, 6400000]);
                },
                'message' => __d('wasabi_core', 'Please choose a valid maximum login time.')
            ])
            ->numeric(
                'Auth__max_login_attempts',
                __d('wasabi_core', 'Please enter a number above 0.')
            )
            ->greaterThan(
                'Auth__max_login_attempts',
                0,
                __d('wasabi_core', 'Please enter a number above 0.')
            )
            ->notEmpty(
                'User__has_username',
                __d('wasabi_core', 'Please choose if users have a username.')
            )
            ->notEmpty(
                'User__has_firstname_lastname',
                __d('wasabi_core', 'Please choose if users have a firstname and lastname.')
            )
            ->notEmpty(
                'User__allow_timezone_change',
                __d('wasabi_core', 'Please choose if users may change his timezone.')
            )
            ->notEmpty(
                'User__belongs_to_many_groups',
                __d('wasabi_core', 'Please choose if users may belong to multiple groups.')
            );
    }
1138976
public function setValidator($validator)
    {
        $this->clearCache();
        $this->validators = [];
        $this->addValidator($validator);

        return $this;
    }
143014
protected function validate($validator)
    {
        $validator->validatePresence('operation');

        // Validation for a new refund request
        if ($this->params['operation'] == 'request')
        {
            $validator->validatePresence('hash');
            $validator->validatePresence('amount');
            $validator->validatePresence('description');
        }
        // Validation a cancel refund request
        else
        {
            $validator->validatePresenceOr('merchant_refund_code', 'refund_id');
        }
    }
73286
protected function registerValidationRules($validator)
    {
        /**
         * elfinder validator
         */
        $validator->resolver(function($translator, $data, $rules, $messages)
        {
            return new BaseValidator($translator, $data, $rules, $messages);
        });
        $validator->replacer('elfinder_max', function($message, $attribute, $rule, $parameters) {
            return str_replace(':size',$parameters[0],$message);
        });
        $validator->replacer('elfinder', function($message, $attribute, $rule, $parameters) {
            return str_replace(':values',implode(', ', $parameters),$message);
        });

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

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

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

		$validator
			->allowEmpty('result');

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

		return $validator;
	}
792014
public function validationDefault(Validator $validator) : Validator
    {
        // configurable in config/csv_migrations.php
        if (! Configure::read('CsvMigrations.tableValidation')) {
            return $validator;
        }

        return $this->validationEnabled($validator);
    }
721552
public function validationEnabled(Validator $validator) : Validator
    {
        $className = App::shortName(get_class($this), 'Model/Table', 'Table');
        $config = (new ModuleConfig(ConfigType::MIGRATION(), $className))->parse();
        $config = json_encode($config);
        if (false === $config) {
            return $validator;
        }
        $config = json_decode($config, true);
        $factory = new FieldHandlerFactory();

        foreach ($config as $column) {
            $validator = $factory->setValidationRules($this, $column['name'], $validator);
        }

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

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

        $validator
            ->boolean('active')
            ->allowEmpty('active');

        $validator
            ->boolean('default')
            ->allowEmpty('default');

        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;
    }