Skip to content
This repository has been archived by the owner on Nov 24, 2018. It is now read-only.

Remove dynamically constraints #46

Closed
maxiplay opened this issue Nov 17, 2014 · 6 comments
Closed

Remove dynamically constraints #46

maxiplay opened this issue Nov 17, 2014 · 6 comments

Comments

@maxiplay
Copy link

Now we can add constraints via the method valdr.addConstraints(...), why not have a method removeConstraints(...) ?

@philippd
Copy link
Collaborator

This can easily be implemented. But what is your use case (besides freeing some memory)? This would be interesting to know to have an API that makes sense. I'd suggest valdr.removeConstraints('Person') and/or valdr.removeConstraints(['Person', 'Address'])

@maxiplay
Copy link
Author

Yes I agree with you and perhaps I am doing an error. I need to remove constraints in order to adapt my validation following the context. When I select a specific field, constraints change

@maxiplay
Copy link
Author

In same idea, it would be the same with customs validators

@philippd
Copy link
Collaborator

I don't think that removing a validator makes sense, or do you see a use case where removing/altering the constraints would not work?
Changing constraints however really helps in some cases.
What you could do as a workaround, until the remove function is implemented, is to delete the constraints for a type with valdr.addConstraints({ 'YourType': {}}).

@maxiplay
Copy link
Author

no it's a mistake of me. And for valdr.addConstrants({ 'YourType': {}}). it's already done !^^

@procoder317
Copy link

can valdr validate variable data which varies per server request. for example OTP changes its length from 3 to 6 chars long. can I validate the user input data against the server fetched otp data.

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

No branches or pull requests

3 participants