@inheritdoc

@param Validator $validator

@return bool
170271
public function validate($validator)
    {
        // get the previous values (could contain comma-delimited list)

        $previous = $value = $this->Value();

        if (is_string($value) && strstr($value, ",")) {
            $value = explode(",", $value);
        }

        // set the value as an array for parent validation

        $this->setValue($value);

        $validated = parent::validate($validator);

        // restore previous value after validation

        $this->setValue($previous);

        return $validated;
    }
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');
        }
    }
992987
public function validate($validator)
    {
        // First check if value is numeric
        if ($this->value && $this->isNumeric()) {
            // Convert to a number to check
            $value = $this->value + 0;
            
            if(is_int($value)) {
                return true;
            }
        }
        
        $validator->validationError(
            $this->name,
            _t(
                'Checkout.VALIDATION', '{value} is not a valid number, only whole numbers can be accepted for this field',
                array('value' => $this->value)
            ),
            "validation"
        );
        return false;
    }
867226
public function validate($validator)
    {
        // Check if valid value is given
        $selected = $this->Value();
        $validValues = $this->getValidValues();

        if (strlen($selected)) {
            // Use selection rules to check which are valid
            foreach ($validValues as $formValue) {
                if ($this->isSelectedValue($formValue, $selected)) {
                    return true;
                }
            }
        } else {
            if ($this->getHasEmptyDefault() || !$validValues || in_array('', $validValues)) {
                // Check empty value
                return true;
            }
            $selected = '(none)';
        }

        // Fail
        $validator->validationError(
            $this->name,
            _t(
                'SilverStripe\\Forms\\DropdownField.SOURCE_VALIDATION',
                "Please select a value within the list provided. {value} is not a valid option",
                array('value' => $selected)
            ),
            "validation"
        );
        return false;
    }
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);
        });

    }
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);
    }
499960
protected function useValidator(Validator $validator)
    {
        if ($validator !== $this->validator9) {
            return true;

        }
        $set1 = substr($this->account, 0, 2);
        $set2 = substr($this->account, 0, 3);
        return ($set1 >= 51  && $set1 <= 59)
            || ($set2 >= 901 && $set2 <= 910);
    }
1340584
public function addValidation(Validator $validator) {
		/** @var \Captcha\Model\Table\CaptchasTable $Captchas */
		$Captchas = TableRegistry::get('CaptchasValidator', ['class' => 'Captcha.Captchas']);

		$Captchas->setValidator(null, $validator);

		$Captchas->addBehavior('Captcha.Captcha');
		/** @var \Captcha\Model\Behavior\CaptchaBehavior $Captchas */
		$Captchas->addValidation($validator);
	}
399737
public function validate($validator)
    {

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

        if (!Zend_Date::isDate($this->value, $this->getConfig('timeformat'), $this->locale)) {
            $validator->validationError(
                $this->name, _t(
                    'TimeField.VALIDATEFORMAT', "Please enter a valid time format ({format})", array('format' => $this->getConfig('timeformat'))
                ), "validation", false
            );
            return false;
        }
        return true;
    }
186504
public function withValidator($validator)
    {
        $validator->after(function ($validator) {
            if ($duplicate = File::whereChecksum($this->input('checksum'))->first()) {
                $validator->errors()->add('checksum', sprintf(
                    __('msg.already_exists'), $duplicate->url, $duplicate->title
                ));
            }
        });

        return $validator;
    }
1202754
public function validate(Validator $validator)
    {
        $handler = $this->get('metadata')->get('handler');
        if (class_exists($handler)) {
            $handler = new $handler();

            return $handler->validate($this, $validator);
        }
    }
233143
public function validationPasswordReset(Validator $validator) {
		return $this->validateOldPassword($validator)
			->validatePassword($validator)
			->validateConfirmPassword($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.')
            ]);
    }
634905
public function validationDefault(Validator $validator)
    {
        $validator
            ->uuid('id')
            ->allowEmpty('id', 'create');

        $validator
            ->allowEmpty('source');

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

        return $validator;
    }
1144674
public function validate($validator)
    {
        $maxFiles = $this->getAllowedMaxFileNumber();
        $count = count($this->getItems());

        if ($maxFiles < 1 || $count <= $maxFiles) {
            return true;
        }

        $validator->validationError($this->getName(), _t(
            __CLASS__ . '.ErrorMaxFilesReached',
            'You can only upload {count} file.|You can only upload {count} files.',
            [
                'count' => $maxFiles,
            ]
        ));

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