Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'0' Number not pass required option. #52

Closed
akhamuliak opened this issue Feb 6, 2018 · 1 comment
Closed

'0' Number not pass required option. #52

akhamuliak opened this issue Feb 6, 2018 · 1 comment
Assignees
Milestone

Comments

@akhamuliak
Copy link

akhamuliak commented Feb 6, 2018

For example if I want to make gender or some other field field as select box and have 0 value for male and 1 for female.

Because of bug I can't set gender field as required, because male selection doesn't pass required validation.

https://github.com/in2code-de/femanager/blob/develop/Classes/Domain/Validator/AbstractValidator.php#L58
It's because empty($var) function return false if $var = 0 or $var = '0'

So I think something like this will solve the issue

protected function validateRequired($value)
    {
        if (!is_object($value)) {
            if (is_numeric($value)) {
                return true;
            }
            return !empty($value);

        } elseif (count($value)) {
            return true;
        }
        return false;
    }
@sbusemann sbusemann self-assigned this Apr 3, 2018
@sbusemann sbusemann added this to the _under investigation milestone May 27, 2019
sbusemann pushed a commit that referenced this issue Jun 21, 2020
As 0 is a value, and not nothing.

Relates: #52
@sbusemann
Copy link
Contributor

this will be in the next release.

@sbusemann sbusemann modified the milestones: next release, 5.3.0 Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants