src/field/Field.php
public function validate()
    {
        $data = $this->wasSubmitted() === true ? $this->getSubmitted() : null;

        // Invalid selection on choice/multiple choice field
        if ($data === []) {
            $this->addError("Unrecognized choice.");
        }

        if ($this->isRequired() === true && $data === null) {
            $this->addError("This field is required.");
        }

        if ($this->getErrors() === []) {
            $this->setValidatedData($data);
        }
    }
public function validate()
    {
        $data = $this->wasSubmitted() === true ? $this->getSubmitted() : null;

        // Invalid selection on choice/multiple choice field
        if ($data === []) {
            $this->addError("Unrecognized choice.");
        }

        if ($this->isRequired() === true && $data === null) {
            $this->addError("This field is required.");
        }

        if ($this->getErrors() === []) {
            $this->setValidatedData($data);
        }
    }
public function validate ( ) { $ data = $ this -> wasSubmitted ( ) === true ? $ this -> getSubmitted ( ) : null ; // Invalid selection on choice/multiple choice field if ( $ data === [ ] ) { $ this -> addError ( "Unrecognized choice." ) ; } if ( $ this -> isRequired ( ) === true && $ data === null ) { $ this -> addError ( "This field is required." ) ; } if ( $ this -> getErrors ( ) === [ ] ) { $ this -> setValidatedData ( $ data ) ; } }
Perform basic validation on the field, add any apparent errors, and
mark valid data.

@return void
Perform basic validation on the field add any apparent errors and mark valid data .