Tyrrrz / CliFx

Class-first framework for building command-line interfaces
MIT License
1.48k stars 60 forks source link

Custom value validators #87

Closed oshustov closed 3 years ago

oshustov commented 3 years ago

Hello :) Here we have a simple implementation of the custom value validators. User have to inherit from a generic ArgumentValueValidator<> and implement validation logic in Validate(YourType value) method. The return type is ValidationResult - a tiny type that provides a simple interface for creating validation results with custom messages.

Basically, there are two abstract types for custom validators: a generic ArgumentValueValidator<> (convenient interface for users) and a non-generic IArgumentValueValidator that used by the framework. I'm not sure about this idea, what do you think?

Example: image

Closes #42

Tyrrrz commented 3 years ago

Thanks :)