Validate this field

@param Validator $validator
@return bool
198200
public function validate($validator)
    {
        if (!is_null($this->maxLength) && mb_strlen($this->value) > $this->maxLength) {
            $validator->validationError(
                $this->name,
                _t(
                    'SilverStripe\\Forms\\TextField.VALIDATEMAXLENGTH',
                    'The value for {name} must not exceed {maxLength} characters in length',
                    array('name' => $this->getName(), 'maxLength' => $this->maxLength)
                ),
                "validation"
            );
            return false;
        }
        return true;
    }
871997
public function validate(ValidatorInterface $validator) {
        $validator->validate($this->getEntity());
        $messages = $validator->getMessages();
        if(is_array($messages)) {
            foreach($messages as $message) {
                $this->getEntity()->appendMessage($message);
            }
        }
    }
867780
protected function failedValidation(Validator $validator)
    {
        throw (new ModelValidationException($validator))
            ->errorBag($this->errorBag)
            ->redirectTo($this->getRedirectUrl());
    }
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;
    }
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;
    }
466001
public function validate($validator)
    {
        $valid = true;
        foreach ($this->children as $child) {
            /** @var FormField $child */
            $valid = ($child && $child->validate($validator) && $valid);
        }
        return $valid;
    }
973732
public function validate($validator)
    {
        parent::validate($validator);

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

        // Use the VideoLink object to validate
        $obj = VideoLink::create()->setValue($this->value);

        if (!$obj->getService()) {
            $validator->validationError(
                $this->name,
                _t(__CLASS__ . '.ValidationError', 'Please enter a valid YouTube or Vimeo link'),
                'validation'
            );
            return false;
        }

        return true;
    }
992686
public function validate($field, $value, $validator) {
		if(strlen($value) === 0) return false;
		$value = (int) $value;
		return $value <= $this->max;
	}
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;
    }
1066769
public function validate($field, $value, $validator) {
		if(empty($value)) return true;
		return (bool) preg_match($this->regex, $value);
	}
337711
public function validationDefault(Validator $validator)
    {
        $validator
            ->notEmpty('handler', __d('field', 'Invalid field type.'))
            ->add('label', [
                'notBlank' => [
                    'rule' => 'notBlank',
                    'message' => __d('field', 'You need to provide a label.'),
                ],
                'length' => [
                    'rule' => ['minLength', 3],
                    'message' => __d('field', 'Label need to be at least 3 characters long'),
                ],
            ]);

        return $validator;
    }
86018
protected function failedValidation(Validator $validator)
    {
        if ($this->container['request'] instanceof Request) {
            throw new ValidationHttpException($validator->errors());
        }

        parent::failedValidation($validator);
    }
1260119
public function addValidator($validator)
    {
        if (!$validator instanceof ValidatorInterface) {
            if (!is_callable($validator)) {
                throw new \InvalidArgumentException('Validator should be callable or ValidatorInterface.');
            }

            $validator = new CallbackValidator($validator);
        }

        $this->validators[] = $validator;

        return $this;
    }
901115
public function isValid(ValidatorInterface $validator)
    {
        $this->violations = $validator->validate($this);

        return 0 === count($this->violations);
    }
601491
protected function validate($validator)
    {
        $validator->validatePresence('currency_code');
        $validator->validatePresence('amount');
        $validator->validatePresence('merchant_payment_code');
        $validator->validatePresence('name');
        $validator->validatePresence('email');
        $validator->validatePresence('payment_type_code');
    }
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;
	}
1347168
protected function useValidator(Validator $validator)
    {
        if (substr($this->account, 2, 2) == '99') {
            return $validator === $this->validators[2]
                || $validator === $this->validators[3];

        } else {
            return  $validator !== $this->validators[2];

        }
    }