Validate field

@return boolean
761158
public function doValidate()
    {
        $isValid = false;
        $value = $this->valRaw();
        $regex = '/^'
            .'[a-z0-9_]+([_\.-][a-z0-9]+)*'     // user
            .'@'
            .'([a-z0-9]+([\.-][a-z0-9]+)*)+'    // domain
            .'(\.[a-z]{2,})'                    // sld, tld
            .'$/i';
        if (\preg_match($regex, $value, $matches)) {
            $this->debug->log('properly formatted');
            $isValid    = true;
            $hostname   = \strtolower($matches[2].$matches[4]);
            $ipaddress  = \gethostbyname($hostname);        // A record
            if ($ipaddress == '92.242.140.2') {
                // bogus
                $ipaddress = $hostname;
            }
            $this->debug->log('hostname', $hostname);
            $this->debug->log('ipaddress', $ipaddress);
            if ($ipaddress != $hostname) {
                $this->debug->log('A record', $ipaddress);
            } elseif ($mxrecord = \getmxrr($hostname, $mxhosts)) {
                $this->debug->log('getmxrr('.$hostname.')', $mxrecord);
            } elseif (\strpos($_SERVER['SERVER_NAME'], $hostname)) {
                $this->debug->log('email domain matches server domain');
            } else {
                $this->debug->warn('unable to verify email');
                $noticeName = $this->attribs['name'].'_notice';
                if (!isset($this->form->currentValues[$noticeName]) || $this->form->currentValues[$noticeName] != $value) {
                    $this->debug->warn('flagging');
                    $this->flag('We were unable to confirm this address.<br />Please confirm before continuing.');
                } else {
                    $this->debug->info('have seen notice');
                }
            }
        }
        $this->debug->log('isValid', $isValid);
        return $isValid;
    }
933878
public function validate() {
        if (!$this->_data) {
            return false;
        }

        $fields = $this->getFields();
        $messages = $this->getMessages();

        foreach ($this->_data as $field => $value) {
            if (empty($this->_rules[$field])) {
                continue;
            }

            foreach ($this->_rules[$field] as $rule => $params) {
                $options = $params['options'];
                $arguments = $options;
                array_unshift($arguments, $value);

                // Use G11n if it is available
                if (class_exists('Titon\G11n\Utility\Validate')) {
                    $class = 'Titon\G11n\Utility\Validate';
                } else {
                    $class = 'Titon\Utility\Validate';
                }

                if (!call_user_func(array($class, 'hasMethod'), $rule)) {
                    throw new InvalidValidationRuleException(sprintf('Validation rule %s does not exist', $rule));
                }

                // Prepare messages
                $message = $params['message'];

                if (!$message && isset($messages[$rule])) {
                    $message = $messages[$rule];
                }

                if ($message) {
                    $message = String::insert($message, array_map(function($value) {
                        return is_array($value) ? implode(', ', $value) : $value;
                    }, $options + array(
                        'field' => $field,
                        'title' => $fields[$field]
                    )));
                } else {
                    throw new InvalidValidationRuleException(sprintf('Error message for rule %s does not exist', $rule));
                }

                if (!call_user_func_array(array($class, $rule), $arguments)) {
                    $this->addError($field, $message);
                    break;
                }
            }
        }

        return empty($this->_errors);
    }
343208
public function validate() {
	
		$app = Application::getInstance();
		
		$valid = TRUE;
	
		$value = Input::get($this->name);

		// checks if empty and required
		if ($this->required and !$value) {
			
			$app->logWarning('Control validation on field “' . $this->name . '” has failed (required)');
			$valid = FALSE;
			
		// checks if value is in allowed list
		} else if (count($this->list)) {
			
			$valid = FALSE;
			
			foreach ($this->list as $item) {
				if ($item->value == $value) $valid = TRUE;
			}

			if (!$valid) {
				$app->logWarning('Control validation on field “' . $this->name . '” has failed (value “' . $value . '” is not in list)');
			}

		}
		
		return $valid;
	
	}
41723
public function validate(): bool
    {
        foreach ($this as $element) {
            if ($element instanceof HasValueValidationInterface) {
                $element->validate();
            }
        }
        return $this->errors()->empty();
    }
910636
public function validate()
	{
		$validity = Rules::validate($this->attributes, $this->getRules());

		if ($validity === true)
		{
			return true;
		}

		$this->setErrors($validity);
		return false;
	}
1374888
public function isValid()
    {
        /**
         * First, check if the upload is valid or not
         */
        if (!parent::isValid()) {
            return false;
        }

        $value = $this->field->getValue();

        // if here, we know that the field is uploaded.

        // check if it's an image, and get it's size
        $size = @getimagesize($value['tmp_name']);
        if ($size === false) {
            $this->setErrorMessage($this->messages['not_an_image']);
            return false;
        }
        list ($width, $height) = $size;

        /**
         * Validate the aspect ratio.
         */
        if (!$this->validateAspectRatio($width, $height)) {
            return false;
        }


        /**
         * Validate the proportions
         */
        if (!$this->validateSize($width, $height)) {
            return false;
        }

        // if here, everything is ok!
        return true;
    }
876766
public function isValidField(string $field): bool {
        $result = empty($this->errors[$field]);
        return $result;
    }
879185
public function isValid()
    {
        // if this token was not validated before...
        if ($this->validated === null) {
            // get the token value
            $token = $this->field->getValue();

            if (!empty($_SESSION) && !empty($_SESSION['csrftokens'])) {
                // if the token is in the list of valid tokens, this field is valid!
                $key = array_search($token, $_SESSION['csrftokens']);
                if ($key !== false) {
                    // invalidate the token as it has already been used.
                    unset($_SESSION['csrftokens'][$key]);

                    $this->validated = true;
                } else {
                    $this->validated = false;
                }
            } else {
                $this->validated = false;
            }
        }

        return $this->validated;
    }
52668
public function validate() {
        $validated = TRUE;

        foreach($this->getFormElements() as $name => $child) {
            $validated &= $child->validate();
        }

        $validated &= $this->fireEvent("Form\onValidate", [ $this->value, $this ], TRUE, FALSE);

        return (bool)$validated;
    }
1233578
public function valid()
    {
        $fieldCount = count($this->record);
        return ($this->at >= 0 && $this->at < $fieldCount);
    }
1368113
public function isValid()
    {
        $value = $this->field->getValue();

        if ($value == '' && $this->required == false) {
            return true;
        }

        if (filter_var($value, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
            return true;
        }

        return false;
    }
369459
public function validate()
    {
        foreach ($this->inputValidations as $name => $data) {
            $validator = $data['callback'];
            $result = $validator($this);
            if ($result === false) {
                $this->logDebug("Validation FAILED: $name");
                $onError = $data['soundOnError'];
                if (is_array($onError)) {
                    foreach ($onError as $msg) {
                        $this->addPrePromptMessage($msg);
                    }
                } elseif (is_string($onError)) {
                    $this->addPrePromptMessage($onError);
                } else {
                    $this->logDebug("Ignoring validation sound: " . print_r($onError, true));
                }
                return false;
            }
            $this->logDebug("Validation OK: $name");
        }
        return true;
    }
15946
public function _validation_match_field($val, $field)
	{
		if ($this->input($field) !== $val)
		{
			$validating = $this->active_field();
			throw new \Validation_Error($validating, $val, array('match_field' => array($field)), array($this->field($field)->label));
		}

		return true;
	}
1246312
protected function validate()
    {
        foreach ($this->_requiredAttr as $attr) {
            if (is_array($attr)) {
                $valid = false;
                foreach ($attr as $sub) {
                    if (!is_null($this->$sub)) {
                        $valid = true;
                        break;
                    }
                }
                if (!$valid) {
                    return false;
                }
            } elseif (is_null($this->$attr)) {
                return false;
            }
        }
        return true;
    }
1289978
public function validate()
    {
        if (($_FILES) && (isset($_FILES[$this->name]['name']))) {
            $value = $_FILES[$this->name]['name'];
            $size  = $_FILES[$this->name]['size'];
        } else {
            $value = null;
            $size  = null;
        }
        // Check if the element is required
        if (($this->required) && empty($value)) {
            $this->errors[] = 'This field is required.';
        }
        // Check field validators
        if (count($this->validators) > 0) {
            foreach ($this->validators as $validator) {
                if ($validator instanceof \Pop\Validator\ValidatorInterface) {
                    $class =  get_class($validator);
                    if ((null !== $size) &&
                        (('Pop\Validator\LessThanEqual' == $class) || ('Pop\Validator\GreaterThanEqual' == $class) ||
                         ('Pop\Validator\LessThan' == $class) || ('Pop\Validator\GreaterThan' == $class))) {
                        if (!$validator->evaluate($size)) {
                            $this->errors[] = $validator->getMessage();
                        }
                    } else {
                        if (!$validator->evaluate($value)) {
                            $this->errors[] = $validator->getMessage();
                        }
                    }
                } else if (is_callable($validator)) {
                    $result = call_user_func_array($validator, [$value]);
                    if (null !== $result) {
                        $this->errors[] = $result;
                    }
                }
            }
        }
        return (count($this->errors) == 0);
    }
1239734
public function isValid()
    {
        $response = call_user_func_array($this->userFunction, array(
            &$this->field
        ));

        if ($response === true) {
            return true;
        }

        if (is_string($response)) {
            $this->setErrorMessage($response);
        }

        return false;
    }
1165983
public function validate()
	{
		$varValue = $this->getPost($this->strName);

		if (!empty($varValue) && !$this->isValidOption($varValue))
		{
			$this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalid'], (is_array($varValue) ? implode(', ', $varValue) : $varValue)));
		}

		parent::validate();
	}