You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Anyone craving a fluent validation style in Validly? The good "old" super-performant, zero-allocation library (Validly) – but with rules in a separate class, where you can ‘happily’ forget to update them after changing your model? 😄
I think I can support something like this:
[Validator<SomeDto>]// [Validator(typeof(SomeDto))]publicpartialclassSomeDtoValidator{staticSomeDtoValidator(){Name.NotEmpty().MinLength(3).MaxLength(50);Age.Between(0,120);}privatestaticValidationBeforeValidate(SomeDtoobj)// Optional; Adaptible signature like current Validly validation{returnValidation.Success();}privatestaticvoidAfterValidate(SomeDtoobj)// Optional; Adaptible signature like current Validly validation{}}
publicpartialclassSomeDtoValidator:global::Validly.Validators.IInternalValidator{// NEW: Validation rule builders for each propertyprivatestaticStringPropertyValidatorName=new();privatestaticIntPropertyValidatorAge=new();// Methods that Validly currently generates here...}
And also it would generate an extension method, so the usage can be the same. Or would it be okay for you if Validate() method were still generated on the object itself? That would make abstract access (e.g., middleware validation) easier and more performant.
I haven’t thought it through in full depth, but I believe it should be possible to write it while still keeping compatibility with the current Validly implementation and developer experience.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Anyone craving a fluent validation style in Validly? The good "old" super-performant, zero-allocation library (Validly) – but with rules in a separate class, where you can ‘happily’ forget to update them after changing your model? 😄
I think I can support something like this:
Validated object:
It would generate something like this:
And also it would generate an extension method, so the usage can be the same. Or would it be okay for you if
Validate()method were still generated on the object itself? That would make abstract access (e.g., middleware validation) easier and more performant.I haven’t thought it through in full depth, but I believe it should be possible to write it while still keeping compatibility with the current Validly implementation and developer experience.
Beta Was this translation helpful? Give feedback.
All reactions