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);
        }
    }