Get comparison value

@param $validator
@param $comparisonField
@return null
3883
protected function getComparisonValue($validator, $comparisonField)
    {
        $comparisonFieldValue = isset($validator->getData()[$comparisonField]) ? $validator->getData()[$comparisonField] : null;
        return $comparisonFieldValue;
    }
366716
public static function isValid($validator, $value)
    {
        /** @var ValidatorInterface $validator */
        $validator = static::create($validator);
        $result = $validator->isValid($value);
        static::$_messages = $validator->getMessages();
        return $result;
    }
841199
public function validate($field, $value, $validator) {
		$value = (int) $value;
		return $value >= $this->min;
	}
1364136
public function validate($validator)
    {
        // Don't validate empty fields
        $this->value = trim($this->value);

        if (empty($this->value)) {
            return true;
        }

        $phone = PhoneNumber::create()->setValue($this->value);

        if (!$phone->Link()) {
            $validator->validationError(
                $this->name,
                _t(__CLASS__ . '.ValidationError', 'Please enter a valid phone number'),
                'validation'
            );
            return false;
        }

        return true;
    }
365749
protected function _setValidator($validator)
    {
        if (!is_null($validator) && !($validator instanceof ValidatorInterface)) {
            throw $this->_createInvalidArgumentException($this->__('Invalid validator'), null, null, $validator);
        }

        $this->validator = $validator;
    }
236764
protected function getValueFromComparison(Comparison $comparison)
    {
        $value = $comparison->getValue()->getValue();

        switch ($comparison->getOperator()) {
            case Comparison::CONTAINS:
                return '%' . $value . '%';
            case Comparison::STARTS_WITH:
                return $value . '%';
            case Comparison::ENDS_WITH:
                return '%' . $value;
            default:
                return $value;
        }
    }
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;
    }
406577
public function validator($validator, $condition = true)
    {
        if (!$condition) {
            return $this;
        }

        if ($validator instanceof \Closure) {
            $this->validators[] = $validator;
        } else {
            $this->rule($validator);
        }

        return $this;
    }
1128458
private function getComparisonField(array $item, string $field)
    {
        if (! isset($item[$field])) {
            throw new InvalidArgumentException(sprintf('Unable to find comparison field %s', $field));
        }

        $value = $item[$field];

        return is_string($value) ? strtolower($value) : $value;
    }
1191902
public function eq($field, $value)
    {
        if(!$value instanceof Part) {
            $value = $this->buildPart($value);
        }
        return new Expr\ComparisonExpression($field, $value, Expr\ComparisonExpression::EQ);
    }
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;
    }
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;
    }
993196
public T withBeanValidator(javax.validation.Validator validator) {
        if (validator != null) {
            configMap.put(BEAN_VALIDATION_VALIDATOR, validator);
            configMap.put(BEAN_VALIDATION_ENABLE, true);
        }
        return getThis();
    }
161624
public function addValidator($validator)
    {
        if (!($validator instanceof ValidatorInterface) && !is_callable($validator)) {
            $validator = ValidatorHelper::create($validator);
        }

        $this->validator->addValidator($validator);

        return $this;
    }
1265004
public function validate($validator) {
        $recaptchaResponse = Controller::curr()->getRequest()->requestVar('g-recaptcha-response');
        if(!isset($recaptchaResponse)) {
            $validator->validationError($this->name, _t('UndefinedOffset\\NoCaptcha\\Forms\\NocaptchaField.EMPTY', '_Please answer the captcha, if you do not see the captcha you must enable JavaScript'), 'validation');
            return false;
        }

        if(!function_exists('curl_init')) {
            user_error('You must enable php-curl to use this field', E_USER_ERROR);
            return false;
        }

        $url='https://www.google.com/recaptcha/api/siteverify?secret='.self::config()->secret_key.'&response='.rawurlencode($recaptchaResponse).'&remoteip='.rawurlencode($_SERVER['REMOTE_ADDR']);
        $ch=curl_init($url);
        $proxy_server=$this->_proxyServer ? $this->_proxyServer : self::config()->proxy_server;
        if(!empty($proxy_server)){
            curl_setopt($ch, CURLOPT_PROXY, $proxy_server);

            $proxy_auth=$this->_proxyAuth ? $this->_proxyAuth : self::config()->proxy_auth;
            if(!empty($proxy_auth)){
                curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_auth);
            }

            $proxy_port=$this->_proxyPort ? $this->_proxyPort : self::config()->proxy_port;
            if(!empty($proxy_port)){
                curl_setopt($ch, CURLOPT_PROXYPORT, $proxy_port);
            }
        }

        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, self::config()->verify_ssl);
        curl_setopt($ch, CURLOPT_USERAGENT, str_replace(',', '/', 'SilverStripe'));
        $response=json_decode(curl_exec($ch), true);

        if(is_array($response)) {
            if(array_key_exists('success', $response) && $response['success']==false) {
                $validator->validationError($this->name, _t('UndefinedOffset\\NoCaptcha\\Forms\\NocaptchaField.EMPTY', '_Please answer the captcha, if you do not see the captcha you must enable JavaScript'), 'validation');
                return false;
            }
        }else {
            $validator->validationError($this->name, _t('UndefinedOffset\\NoCaptcha\\Forms\\NocaptchaField.VALIDATE_ERROR', '_Captcha could not be validated'), 'validation');
            $logger = Injector::inst()->get(LoggerInterface::class);
            $logger->error(
                'Captcha validation failed as request was not successful.'
            );
            return false;
        }


        return true;
    }
673478
public function validate($validator)
    {
        $name = $this->name;

        // if field isn't visible, don't validate
        if (!$this->isSaveable()) {
            return true;
        }

        $this->getPasswordField()->setValue($this->value);
        $this->getConfirmPasswordField()->setValue($this->confirmValue);
        $value = $this->getPasswordField()->Value();

        // both password-fields should be the same
        if ($value != $this->getConfirmPasswordField()->Value()) {
            $validator->validationError(
                $name,
                _t('SilverStripe\\Forms\\Form.VALIDATIONPASSWORDSDONTMATCH', "Passwords don't match"),
                "validation"
            );

            return false;
        }

        if (!$this->canBeEmpty) {
            // both password-fields shouldn't be empty
            if (!$value || !$this->getConfirmPasswordField()->Value()) {
                $validator->validationError(
                    $name,
                    _t('SilverStripe\\Forms\\Form.VALIDATIONPASSWORDSNOTEMPTY', "Passwords can't be empty"),
                    "validation"
                );

                return false;
            }
        }

        // lengths
        $minLength = $this->getMinLength();
        $maxLength = $this->getMaxLength();
        if ($minLength || $maxLength) {
            $errorMsg = null;
            $limit = null;
            if ($minLength && $maxLength) {
                $limit = "{{$minLength},{$maxLength}}";
                $errorMsg = _t(
                    __CLASS__ . '.BETWEEN',
                    'Passwords must be {min} to {max} characters long.',
                    ['min' => $minLength, 'max' => $maxLength]
                );
            } elseif ($minLength) {
                $limit = "{{$minLength}}.*";
                $errorMsg = _t(
                    __CLASS__ . '.ATLEAST',
                    'Passwords must be at least {min} characters long.',
                    ['min' => $minLength]
                );
            } elseif ($maxLength) {
                $limit = "{0,{$maxLength}}";
                $errorMsg = _t(
                    __CLASS__ . '.MAXIMUM',
                    'Passwords must be at most {max} characters long.',
                    ['max' => $maxLength]
                );
            }
            $limitRegex = '/^.' . $limit . '$/';
            if (!empty($value) && !preg_match($limitRegex, $value)) {
                $validator->validationError(
                    $name,
                    $errorMsg,
                    "validation"
                );

                return false;
            }
        }

        if ($this->getRequireStrongPassword()) {
            if (!preg_match('/^(([a-zA-Z]+\d+)|(\d+[a-zA-Z]+))[a-zA-Z0-9]*$/', $value)) {
                $validator->validationError(
                    $name,
                    _t(
                        'SilverStripe\\Forms\\Form.VALIDATIONSTRONGPASSWORD',
                        'Passwords must have at least one digit and one alphanumeric character'
                    ),
                    "validation"
                );

                return false;
            }
        }

        // Check if current password is valid
        if (!empty($value) && $this->getRequireExistingPassword()) {
            if (!$this->currentPasswordValue) {
                $validator->validationError(
                    $name,
                    _t(
                        __CLASS__ . '.CURRENT_PASSWORD_MISSING',
                        'You must enter your current password.'
                    ),
                    "validation"
                );
                return false;
            }

            // Check this password is valid for the current user
            $member = Security::getCurrentUser();
            if (!$member) {
                $validator->validationError(
                    $name,
                    _t(
                        __CLASS__ . '.LOGGED_IN_ERROR',
                        "You must be logged in to change your password."
                    ),
                    "validation"
                );
                return false;
            }

            // With a valid user and password, check the password is correct
            $authenticators = Security::singleton()->getApplicableAuthenticators(Authenticator::CHECK_PASSWORD);
            foreach ($authenticators as $authenticator) {
                $checkResult = $authenticator->checkPassword($member, $this->currentPasswordValue);
                if (!$checkResult->isValid()) {
                    $validator->validationError(
                        $name,
                        _t(
                            __CLASS__ . '.CURRENT_PASSWORD_ERROR',
                            "The current password you have entered is not correct."
                        ),
                        "validation"
                    );
                    return false;
                }
            }
        }

        return true;
    }
804213
public function getByCondition($key, $comparator, $value = null)
    {
        $query = $this->createQuery();
        $conditionSet = $query->buildAndSet([$key, $comparator, $value]);
        return $this->getByConditionSet($conditionSet);
    }