HTML5 validation attributes based on "validate".

@return void
519431
protected function make_fields_validation() {
		foreach ( $this->fields as $key => $field ) {
			if ( $this->maybe_skip_field( $field ) ) {
				continue;
			}

			if ( $rules = $field->get_option( 'validate' ) ) {
				$attributes = ( new Rules_Parser( $field ) )->parse( $rules );
				$field->set_attribute( $attributes );
			}
		}
	}
120414
private static function validation()
    {
        $files = ['Validator', 'ValidationResult'];
        $folder = static::$root.'Validation'.'/';

        self::call($files, $folder);

        //Initiate the validation surface
        Validator::ini();
    }
446824
function(attrs, options) {
      if (options.silent || !this.validate) {
        return true;
      }
      attrs = _.extend({}, this.attributes, attrs);
      var error = this.validate(attrs, options);
      if (!error) {
        return true;
      }
      if (options && options.error) {
        options.error(this, error, options);
      } else {
        this.trigger('error', this, error, options);
      }
      return false;
    }
102568
private function validateAttributes()
    {
        if (null === $this->apiUrl) {
            throw new BuildException('Wiki apiUrl is required');
        }

        if (null === $this->id && null === $this->title) {
            throw new BuildException('Wiki page id or title is required');
        }
    }
234849
public function validate() : void
    {
        $this->value = null;
        $value = $this->filter($this->raw_value);
        if (true === $this->checkValidity($value)) {
            $this->is_valid = true;
        } else {
            $this->is_valid = false;
            $this->reportError($this->error_message);
            $error_message = sprintf($this->error_message, $this->field_name);
            $this->the_message = $error_message;
        }
        // If no issues have been found, check the constraints.
        if ($this->is_valid) {
            foreach ($this->constraints as $constraint) {
                if (false === $constraint->check($value)) {
                    $this->is_valid = false;
                    $this->the_message = sprintf($constraint->getErrorMessage(), $this->field_name);
                }
            }
        }
        // Set the value for retrieval
        if ($this->is_valid) {
            $this->value = $value;
        }
    }
397479
protected function validationData()
    {
        return $this->merge([
            // default value to the checkbox
            'on_mainpage' => $this->input('on_mainpage', 0),
            'is_pinned' => $this->input('is_pinned', 0),
            'is_catpinned' => $this->input('is_catpinned', 0),
            'is_favorite' => $this->input('is_favorite', 0),
        ])->all();
    }
587274
protected function prepareForValidation(): void
    {
        $data = $this->all();

        $country = $data['country_code'] ?? null;
        $email = $data['email'] ?? null;
        $phone = $data['phone'] ?? null;
        $user = $this->user($this->route('guard'));
        $twoFactor = $user->getTwoFactor();

        if ($email !== $user->email) {
            $data['email_verified_at'] = null;
        }

        if ($phone !== $user->phone || $country !== $user->country_code) {
            $data['phone_verified_at'] = null;
        }

        if ($twoFactor || is_null($data['phone_verified_at'])) {
            array_set($twoFactor, 'phone.enabled', false);
            $data['two_factor'] = $twoFactor;
        }

        $this->replace($data);
    }
934507
protected function validateAttributes()
    {
        if ($this->file !== null && $this->file->isDirectory()) {
            if (($this->destFile !== null && $this->destDir !== null)
                || ($this->destFile === null && $this->destDir === null)
            ) {
                throw new BuildException("One and only one of tofile and todir must be set.");
            }

            if ($this->destFile === null) {
                $this->destFile = new PhingFile($this->destDir, $this->file->getName());
            }

            if ($this->destDir === null) {
                $this->destDir = $this->destFile->getParentFile();
            }

            $this->completeDirMap[$this->file->getAbsolutePath()] = $this->destFile->getAbsolutePath();

            $this->file = null;
        } else {
            parent::validateAttributes();
        }
    }
801360
private final function loadValidation(): void
    {
        $this->validation = new Validation();

        $rules = $this->config->get('validation.rules');
        if ($rules != null) {
            $this->validation->setRules($rules);
        }
    }
726387
protected function performValidation()
    {
        $this->requireProperties(['name', 'in']);
        if ($this->in === 'path') {
            $this->requireProperties(['required']);
            if (!$this->required) {
                $this->addError("Parameter 'required' must be true for 'in': 'path'.");
            }
        }
        if (!empty($this->content) && !empty($this->schema)) {
            $this->addError("A Parameter Object MUST contain either a schema property, or a content property, but not both. ");
        }
    }
60434
public function validateAttribute($model, $attribute)
    {
        $value = $model->$attribute;
        $result = $this->validateValue($value);

        if (!empty($result)) {
            $this->addError($model, $attribute, $this->renderMessage($model, $attribute));
        }
    }
1137576
private function validate()
    {
        // Try to resolve subrules if there are any
        // as a final step before running the validator.
        $this->resolveSubrules();

        // Apply input filters.
        $filters = new Filters($this->inputs, $this->filters, $this);
        $this->inputs = $filters->apply();

        // Apply custom rules.
        $this->customRules();

        $this->validator = $this->validator->make($this->inputs, $this->rules, $this->messages);

        // Apply attributes.
        $this->validator->setAttributeNames($this->attributes);

        // Run the 'after' method, letting the
        // user execute code after validation.
        if (method_exists($this, 'after')) {
            $this->after($this->validator);
        }
    }
631190
def validate_required_attributes!
      unless required_attributes?
        blank_attribute = required_attributes.detect { |attr| self[attr].nil? || self[attr].empty? }

        raise ValidationError, "#{blank_attribute} can't be blank"
      end
    end
335134
final public function validate(): bool
    {
        // validate csrf token if required
        if ($this->_tokenRequired && !$this->_tokenOk) {
            App::$Session->getFlashBag()->add('warning', __('Hack attention: security token is wrong!'));
            return false;
        }
        // get all rules as array from method rules()
        $rules = $this->rules();
        // get default values of attributes
        $defaultAttr = $this->getAllProperties();

        // start validation: on this step class attribute values will be changed to input data if it valid
        $success = $this->runValidate($rules);

        // get not-passed validation fields as array
        $badAttributes = $this->getBadAttributes();
        // prevent warnings
        if (Any::isArray($badAttributes) && count($badAttributes) > 0) {
            foreach ($badAttributes as $attr) {
                if (Str::contains('.', $attr)) { // sounds like dot-separated array attr
                    $attrName = strstr($attr, '.', true); // get attr name
                    $attrArray = trim(strstr($attr, '.'), '.'); // get dot-based array path

                    $defaultValue = new DotData($defaultAttr); // load default attr

                    $dotData = new DotData($this->{$attrName}); // load local attr variable
                    $dotData->set($attrArray, $defaultValue->get($attr)); // set to local prop. variable default value

                    $this->{$attrName} = $dotData->export(); // export to model
                } else {
                    $this->{$attr} = $defaultAttr[$attr]; // just set ;)
                }
                // add message about wrong attribute to session holder, later display it
                $attrLabel = $attr;
                if ($this->getLabel($attr) !== null) {
                    $attrLabel = $this->getLabel($attr);
                }

                App::$Session->getFlashBag()->add('warning', __('Field "%field%" is incorrect', ['field' => $attrLabel]));
            }
        }

        return $success;
    }
1120623
public function check($data)
    {
        $this->validAttribs   = array();
        $this->invalidAttribs = array();
        $this->missingAttribs = array();
        $this->unknownAttribs = array();
        $requiredDependent    = array();
        $seenAttrib           = array();

        foreach (U::flatten($data) as $attribName => $value) {
            $attrib = $this->dataFilter->getAttrib($attribName);
            if (!$attrib) {
                $parts = explode(U::$FLATTEN_SEPARATOR, $attribName);
                $count = count($parts);
                if ($count > 1) {

                    for ($i = $count -1; $i >= 1; $i--) {
                        $testName = join(U::$FLATTEN_SEPARATOR, array_splice($parts, 0, $i));
                        $attrib   = $this->dataFilter->getAttrib($testName. U::$FLATTEN_SEPARATOR. '*');
                        if ($attrib) {
                            break 1;
                        }
                    }
                }
            }
            $seenAttrib[$attribName] = true;

            // unknown attrib
            if (!$attrib) {
                $this->unknownAttribs[$attribName] = $this->dataFilter->applyFilter('pre', $value);
                continue;
            }

            // run pre-filters
            if ($attrib->useFilters()) {
                $value = $this->dataFilter->applyFilter('pre', $attrib->applyFilter('pre', $value));
            }

            // successfull check
            if ($attrib->check($value)) {
                $this->validAttribs[$attribName] = array(
                    'value'  => $attrib->useFilters()
                        ? $this->dataFilter->applyFilter('post', $attrib->applyFilter('post', $value))
                        : $value,
                    'attrib' => &$attrib
                );

                // determine possible dependents
                $attrib->determineDependents($value, $requiredDependent);
            }

            // checks failed
            else {
                $this->invalidAttribs[$attribName] = array(
                    'value'  => $value,
                    'attrib' => &$attrib,
                    'error'  => $attrib->getError()
                );
            }
        }

        // check now all attribs for required
        foreach ($this->dataFilter->getAttribs() as $attribName => $attrib) {

            // already seen
            if (isset($seenAttrib[$attribName])) {
                continue;
            }

            // has default
            elseif (!is_null($default = $attrib->getDefault())) {
                $this->validAttribs[$attribName] = ['value' => $default, 'attrib' => &$attrib];
            }

            // required -> missing
            elseif ($attrib->isRequired() || isset($requiredDependent[$attribName])) {
                $parts = explode(U::$FLATTEN_SEPARATOR, $attribName);
                $count = count($parts);
                if ($count > 1 && $parts[$count-1] === '*') {
                    $before = join(U::$FLATTEN_SEPARATOR, array_splice($parts, 0, $count - 1)). U::$FLATTEN_SEPARATOR;
                    $seen   = array_filter(array_keys($seenAttrib), function ($check) use ($before) {
                        return strpos($check, $before) === 0;
                    });
                    if (count($seen) > 0) {
                        continue;
                    }
                }
                $this->missingAttribs[$attribName] = array(
                    'attrib' => &$attrib,
                    'error'  => $attrib->getMissingText()
                );
            }
        }

        /*error_log("INVALID: ". count($this->invalidAttribs));
        error_log("MISSING: ". count($this->missingAttribs));*/
        return !$this->hasError();
    }
910636
public function validate()
	{
		$validity = Rules::validate($this->attributes, $this->getRules());

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

		$this->setErrors($validity);
		return false;
	}
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;
    }