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

Allow implementing own validator which (also) validates NotEmpty #25

Closed
boesing opened this issue Jan 15, 2021 · 1 comment
Closed

Allow implementing own validator which (also) validates NotEmpty #25

boesing opened this issue Jan 15, 2021 · 1 comment

Comments

@boesing
Copy link
Member

boesing commented Jan 15, 2021

Feature Request

Q A
New Feature yes
RFC kinda
BC Break no

Summary

Hey there,

I've seen #10 and the work which has been done in former zendframework package.
I am not sure if @Maks3w is still working on this but I'd like to propose some kind of NotEmptyValidatorImplementedInterface, which tells the \Laminas\InputFilter\Inputobject, that it does not have to add the NotEmpty validator to the ValidatorChain.

Even tho this feature is deprecated and with v3 of this package it would've been necessary to add the NotEmpty validator manually, I have to work with the current implementation and this implementation does not allow me to handle NotEmpty by myself.

So - why do I need this?

We want to keep things simple and specify own validators for all Form Elements.
So in case, one Element needs more than one validator, we just implement that validator as some kind of chain.

This gives us the flexibility of re-using that validator in multiple forms and we could specify dedicated NotEmpty messages for each element (without having to use the existing annotation/logic - I know that there is such a thing ;-) ).

So, in the current implementation, the NotEmpty validator kicks in when the field is empty. But we want to specify own error messages for the NotEmpty validation and we dont want to use the existing Annotation (we are using Annotations) as that would require unreadable annotation specs and further more - when re-using validators we have to copy & paste that to all other implementations.

What would be the next steps?

  1. I'd like to create a PR (or probably a colleague) which provides the new interface NotEmptyValidatorImplementedInterface.
  2. That interface is being verified within Laminas\InputFilter\Input:: injectNotEmptyValidator until v3 removes that method so we can skip the injection without adding NotEmpty manually.
  3. Mark NotEmptyValidatorImplementedInterface as deprecated in the initial implementation

Any vetos here?

@boesing boesing added this to the 2.12.0 milestone Jan 15, 2021
@boesing
Copy link
Member Author

boesing commented Jan 15, 2021

Ah, nvm - we can just use the deprecated annotation @AllowEmpty
Just had too less informations to understand the initial problem of my team.

@boesing boesing closed this as completed Jan 15, 2021
@boesing boesing removed this from the 2.12.0 milestone Jan 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant