OO design patterns to use for validation

前端 未结 4 1726
感情败类
感情败类 2021-01-31 21:38

I am in the process of writing some validation code based on these assumptions:

  • Validation code must be in an external class
    • i.e. no data class contains
4条回答
  •  無奈伤痛
    2021-01-31 22:09

    I think I am doing the same thing right now.
    The pattern that applies here is the Filter pattern and the Filter Chain.

    Each filter validates against one "way" (as you call them).
    First for syntax, second for Db lookups etc (from your second bullet).

提交回复
热议问题