src/Utility/Validator.php
public function validate($addable)
	{
		foreach ($addable->elements as $element) {

			$classes = class_parents($element);

			// no validation needed
			if (in_array("HtmlForm\Elements\Parents\Html", $classes)) {
				continue;
			}

			if (in_array("HtmlForm\Abstracts\Addable", $classes)) {

				// validate this addable (fieldset)
				$moreErrors = $this->validate($element);

			} else {

				$class = $this->findclass($element);

				if ($class == "honeypot") {
					$value = $element->getRawValue();
					$this->honeypot($value);
					continue;
				}

				// validate this element
				$elementErrors = $element->validate();

				// add new errors to the list
				$this->errors = array_merge($this->errors, $elementErrors);

			}

		}

		return empty($this->errors);
	}
public function validate($addable)
	{
		foreach ($addable->elements as $element) {

			$classes = class_parents($element);

			// no validation needed
			if (in_array("HtmlForm\Elements\Parents\Html", $classes)) {
				continue;
			}

			if (in_array("HtmlForm\Abstracts\Addable", $classes)) {

				// validate this addable (fieldset)
				$moreErrors = $this->validate($element);

			} else {

				$class = $this->findclass($element);

				if ($class == "honeypot") {
					$value = $element->getRawValue();
					$this->honeypot($value);
					continue;
				}

				// validate this element
				$elementErrors = $element->validate();

				// add new errors to the list
				$this->errors = array_merge($this->errors, $elementErrors);

			}

		}

		return empty($this->errors);
	}
public function validate ( $ addable ) { foreach ( $ addable -> elements as $ element ) { $ classes = class_parents ( $ element ) ; // no validation needed if ( in_array ( "HtmlForm\Elements\Parents\Html" , $ classes ) ) { continue ; } if ( in_array ( "HtmlForm\Abstracts\Addable" , $ classes ) ) { // validate this addable (fieldset) $ moreErrors = $ this -> validate ( $ element ) ; } else { $ class = $ this -> findclass ( $ element ) ; if ( $ class == "honeypot" ) { $ value = $ element -> getRawValue ( ) ; $ this -> honeypot ( $ value ) ; continue ; } // validate this element $ elementErrors = $ element -> validate ( ) ; // add new errors to the list $ this -> errors = array_merge ( $ this -> errors , $ elementErrors ) ; } } return empty ( $ this -> errors ) ; }
Runs through the validation required by
each form element.
@param  object $addable Object that extends from \HtmlForm\Abstracts\Addable
@return array Found errors
Runs through the validation required by each form element .