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

Deprecate and remove SPACE case for NotEmpty validator #229

Open
Xerkus opened this issue Feb 22, 2024 · 1 comment
Open

Deprecate and remove SPACE case for NotEmpty validator #229

Xerkus opened this issue Feb 22, 2024 · 1 comment
Labels

Comments

@Xerkus
Copy link
Member

Xerkus commented Feb 22, 2024

NotEmpty validator considers string ' ' empty by default due to space case. It is a surprising behavior that apparently got inherited from ZF1 over 12 years ago.

protected $defaultType = [
self::OBJECT,
self::SPACE,
self::NULL,
self::EMPTY_ARRAY,
self::STRING,
self::BOOLEAN,
];

In case of laminas-inputfilter it would be a filter responsibility to remove spaces or anything else like line feed before validation.

I would say this condition is useful only for laminas-form and only for a sloppy input filter definitions. This case should really be handled by the trim filter.

@gsteel
Copy link
Member

gsteel commented Jul 16, 2024

I kind of agree, but validator does not depend on filter or input-filter - I don't think it's unreasonable to consider as a validation failure by default. You could make the argument that input should be filtered by the ToNull filter which would negate the need for self::STRING and self::EMPTY_ARRAY too probably.

If you have strong feelings here, v3 is getting pretty close…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants