Selecting the design pattern for validation

I am looking into some design pattern which helps me for validation. Please let me know if you have any suggestion.

I thought about using strategy but not sure whether its correct or not

Thanks
There is no "correct" way to do something, only ones that suits you. Patterns exist to solve some common problems. Without in-depth information it is imposible to say if it is right or not.

For example if you have some entity wich handles user input, checking it, outputting errors and asking again, and all what differs for different inputs is validation algorithm, then yes, strategy is a good choice here.
> I thought about using strategy but not sure whether its correct or not

Yes. Strategy is almost always the right pattern for this.

The xxx_get facets are canonical standard library examples of strategy objects used for parsing input.

Ideally use separate components; one for parsing/validation of data and another for the error-handling logic (notify the user of errors, prompt for re-entering manually typed in values, log the error to persistent storage etc.)
Thank you
Topic archived. No new replies allowed.