-1

For data validation, Python coders frequently will use this library called Voluptuous. Is a great library to validate data before processing it further in the code.

Is there any equivalent NuGet library we can use in C#?

Below is a python snippet on how to use voluptuous in python

from voluptuous import Required, All, Length, Range
schema = Schema({
   Required('q'): All(str, Length(min=1)),
   Required('per_page', default=5): All(int, Range(min=1, max=20)), 'page': All(int, Range(min=0))
})
Dennis
  • 3,528
  • 4
  • 28
  • 40
  • Unsure why the close was necessary. Equivalent language feature (i.e. methods or types) questions seem okay, but equivalent libraries aren't? The on-topic guide clearly states that questions about "software tools commonly used by programmers" are on-topic questions. – jhmckimm Dec 23 '21 at 04:42
  • @jhmckimm [What topics can I ask about here?](https://stackoverflow.com/help/on-topic): _"Some questions that fit into one of the categories listed above may be closed by the community because they aren't generally a good fit here or need additional information:"_ _"**Questions asking us to recommend or find a** book, tool, software **library**, tutorial or other off-site resource **are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.**"_ – ProgrammingLlama Dec 23 '21 at 04:51
  • There's a specific close vote reason in the close vote dialog for questions asking for libraries. A request for library recommendations might be on topic on [Software Recommendations](https://softwarerecs.stackexchange.com/) instead. – ProgrammingLlama Dec 23 '21 at 04:52
  • Sorry if my post is not appropriate, just hope to improve my coding and helping others who facing the same issue as me. – Dennis Dec 23 '21 at 06:51

1 Answers1

0

I'm unsure how well it pairs to Voluptuous (I'm not a user of Python at all), but FluentValidation is a library that I like and use often. It's pretty flexible and has met my needs easily so far.

There is also the option of using the native data annotations, but this is less flexible and couples things too closely for my personal liking. I use these only in very rare cases.

jhmckimm
  • 870
  • 6
  • 15
  • Just tried, is not exactly a drop in code, but is pretty good & close to what I need to better validate all my incoming data, thanks! – Dennis Dec 23 '21 at 06:49