question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Abstract validators arguments passing

See original GitHub issue

Hello,

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:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
jgouxcommented, Dec 2, 2019

Thanks a lot for the feature! 🌟

1reaction
jgouxcommented, Nov 20, 2019

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? 😄

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found