Abstract validators arguments passing
See original GitHub issueHello,
Great work on this library, I like the more functional approach it takes with validators as an array!
I was wondering why do we have to pass the validator key as in [Validators.required.validator]
instead of [Validators.required]
?
I think that it adds noise, and the validation function consuming the array could call it itself?
Something like this would be very nice :
import { createFormValidation, Validators as V } from '@lemoncode/fonk';
const validationSchema = {
field: {
user: [V.required, { validator: V.minLength, customArgs: { length: 10 }}]
},
};
export const formValidation = createFormValidation(validationSchema);
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Fluent Validation - pass parameter to collection validator
In your SetCollectionValidator class you have to create a constructor accepting your model as a parameter (or anything else you'd like to pass...
Read more >Pass in arguments to function used in Must predicate #1129
I'm using the Must predicate to define a rule for one of the properties in the object that I'm validating, this has worked...
Read more >Custom Validators — FluentValidation documentation
There are several ways to create a custom, reusable validator. The recommended way is ... We also pass in the number of items...
Read more >writing a fluent validation custom validator with multiple ...
FluentValidation is a .NET framework used to validate objects and values of properties inside an object. It allows you to write different ...
Read more >Built-In, Nested, Custom Validators with FluentValidation
In this article we are going to learn more about different Validators with FluentValidation, that we can use to protect our app from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks a lot for the feature! 🌟
Hello Braulio,
I understand the idea behind wrapping the validator but maybe you could accept the
FieldValidator
type as well in the validators array here and when one is passed, call its validator’s key? Best of both worlds? 😄