Default validation rules set.

@param \Cake\Validation\Validator $validator The validator object
@return \Cake\Validation\Validator
774295
public function validationDefault(Validator $validator)
    {
        $validator
            ->allowEmpty('url')
            ->add('url', 'checkUrl', [
                'rule' => function ($url, $context) {
                    $plainString = (
                        strpos($url, 'javascript:') === 0 ||
                        strpos($url, 'mailto:') === 0 ||
                        strpos($url, 'tel:') === 0 ||
                        strpos($url, 'sms:') === 0 ||
                        strpos($url, '#') === 0 ||
                        strpos($url, '?') === 0 ||
                        strpos($url, '//') === 0 ||
                        strpos($url, '://') !== false
                    );

                    if ($plainString) {
                        return true;
                    } else {
                        $full = Validation::url($url);
                        $internal = str_starts_with($url, '/');

                        return $full || $internal;
                    }
                },
                'message' => __d('menu', 'Invalid URL. Internal links must start with "/", e.g. "/article-my-first-article{0}"', CONTENT_EXTENSION),
                'provider' => 'table',
            ])
            ->requirePresence('title')
            ->add('title', [
                'notBlank' => [
                    'rule' => 'notBlank',
                    'message' => __d('menu', 'You need to provide a title.'),
                ],
                'length' => [
                    'rule' => ['minLength', 3],
                    'message' => __d('menu', 'Title need to be at least 3 characters long.'),
                ],
            ])
            ->add('activation', 'validActivation', [
                'rule' => function ($value, $context) {
                    return in_array($value, ['auto', 'any', 'none', 'php']);
                },
                'message' => __d('menu', 'Please select an activation method.'),
                'provider' => 'table',
            ])
            ->allowEmpty('active')
            ->add('active', 'validPHP', [
                'rule' => function ($value, $context) {
                    if (!empty($context['data']['activation']) && $context['data']['activation'] === 'php') {
                        return strpos($value, '<?php') !== false && strpos($value, '?>') !== false;
                    }

                    return true;
                },
                'message' => __d('menu', 'Invalid PHP code, make sure that tags "&lt;?php" & "?&gt;" are present.')
            ]);

        return $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;
    }
704390
public function addValidation(Validator $validator) {
		$validator->requirePresence('captcha_result');
		$validator->add('captcha_result', [
			'required' => [
				'rule' => 'notBlank',
				'last' => true
			],
		]);

		/** @deprecated Use PassiveCaptcha Behavior */
		if ($this->getConfig('dummyField')) {
			$validator->requirePresence($this->getConfig('dummyField'));
			$validator->allowEmpty($this->getConfig('dummyField'));
			$validator->add($this->getConfig('dummyField'), [
				'dummyField' => [
					'rule' => function ($value, $context) {
						return $value === '';
					},
					'last' => true
				],
			]);
		}

		$this->_engine->buildValidator($validator);
		if ($this->getConfig('minTime')) {
			$validator->add('captcha_result', [
				'minTime' => [
					'rule' => 'validateCaptchaMinTime',
					'provider' => 'table',
					'message' => __('You were too fast'),
					'last' => true
				],
			]);
		}
		if ($this->getConfig('maxTime')) {
			$validator->add('captcha_result', [
				'maxTime' => [
					'rule' => 'validateCaptchaMaxTime',
					'provider' => 'table',
					'message' => __('You were too slow'),
					'last' => true
				],
			]);
		}
	}
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));

    }
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;
    }
989691
public function validationDefault(Validator $validator)
    {
        $validator
            ->integer('id')
            ->allowEmpty('id', 'create');

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

        $validator
            ->allowEmpty('description');

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

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

        $validator
            ->date('deadline')
            ->allowEmpty('deadline');

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

        return $validator;
    }
1238921
public function validationRequestPassword(Validator $validator) {
		$validator = $this->_table->validationDefault($validator);
		$validator->remove($this->_field('email'), 'unique');

		return $validator;
	}
674170
public function validationDefault(Validator $validator)
    {
        $validator
            ->add('id', 'valid', ['rule' => 'numeric'])
            ->allowEmpty('id', 'create')
            ->add('email', 'valid', ['rule' => 'email'])
            ->requirePresence('email', 'create')
            ->notEmpty('email')
            ->add('email', 'unique', ['rule' => 'validateUnique', 'provider' => 'table'])
            ->notEmpty('password');

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

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


        return $validator;
    }
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;
    }
818755
public function validationDefault(Validator $validator) {
        $validator
                ->allowEmpty('id', 'create')
                ->requirePresence('parent', 'create')
                ->notEmpty('parent')
                ->requirePresence('name', 'create')
                ->notEmpty('name')
                ->add('name', 'unique', ['rule' => 'validateUnique', 'provider' => 'table'])
                ->requirePresence('content_title', 'create')
                ->notEmpty('content_title')
                ->requirePresence('content_description', 'create')
                ->notEmpty('content_description')
                ->requirePresence('content_excerpt', 'create')
                ->notEmpty('content_excerpt')
                ->add('content_deadline', 'valid', ['rule' => 'datetime'])
                ->requirePresence('content_deadline', 'create')
                ->notEmpty('content_deadline')
                ->requirePresence('content_password', 'create')
                ->notEmpty('content_password')
                ->requirePresence('content_status', 'create')
                ->notEmpty('content_status')
                ->requirePresence('content_path', 'create')
                ->notEmpty('content_path')
                ->requirePresence('content_type', 'create')
                ->notEmpty('content_type')
                ->requirePresence('content_mime_type', 'create')
                ->notEmpty('content_mime_type')
                ->add('publish_start', 'valid', ['rule' => 'datetime'])
                ->requirePresence('publish_start', 'create')
                ->notEmpty('publish_start')
                ->add('publish_end', 'valid', ['rule' => 'datetime'])
                ->requirePresence('publish_end', 'create')
                ->notEmpty('publish_end')
                ->add('author', 'valid', ['rule' => 'numeric'])
                ->requirePresence('author', 'create')
                ->notEmpty('author')
                ->add('menu_order', 'valid', ['rule' => 'numeric'])
                ->requirePresence('menu_order', 'create')
                ->notEmpty('menu_order');

        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);
    }
1092642
public function addValidator(Validator $validator) : ValidationCheckerInterface
    {
        $this->validated = false;
        $validator->setValidationSet($this);
        array_push($this->validators, $validator);
        return $this;
    }
1249350
public function validationDefault(Validator $validator)
    {
        $validator
            ->allowEmpty('id', 'create')
            ->requirePresence('filepath', 'create')
            ->notEmpty('filepath')
            ->requirePresence('filename', 'create')
            ->notEmpty('filename')
            ->requirePresence('filetype', 'create')
            ->notEmpty('filetype')
            ->add('filesize', 'valid', ['rule' => 'numeric'])
            ->requirePresence('filesize', 'create')
            ->notEmpty('filesize')
            ->requirePresence('model', 'create')
            ->notEmpty('model')
            ->requirePresence('foreign_key', 'create')
            ->notEmpty('foreign_key');

        return $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;
    }
675659
public function validator()
    {
        return Validator::make(
            $this->params, $this->rules(),
            $this->messages(), $this->attributes()
        );
    }
288897
public function validationDefault(Validator $validator)
    {
        $validator
            ->integer('id')
            ->allowEmpty('id', 'create');

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

        $validator
            ->email('email')
            ->allowEmpty('email');

        $validator
            ->allowEmpty('username');

        $validator
            ->allowEmpty('password');

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

        return $validator;
    }
1158687
public function setValidator(Validator $validator)
    {
        $this->validator = $validator;
        
        $validator->configureRule($this);
        
        return $this;
    }