public function validate(Model $model, $value)
    {
        if (!empty($this->choices) && !empty($value)) {
            foreach ($this->choices as $key => $choice) {
                if (is_array($choice)) {
                    foreach ($choice as $inkey => $inchoice) {
                        if ($value === $inchoice) {
                            return;
                        }
                    }
                } else {
                    if ($value === $choice) {
                        return;
                    }
                }
            }

            throw new ValidationError(
                sprintf('Value %s is not a valid choice.', $value),
                'invalid_choice'
            );
        }

        if (is_null($value) && !$this->isNull()) {
            throw new ValidationError('This field cannot be null.', 'null');
        }

        if (empty($value) && !$this->formBlank) {
            throw new ValidationError('This field cannot be blank.', 'blank');
        }
    }