I'm writing this in node.js
I have some data that needs validating before anything can be done with this. The data is validated in two different ways. I can use JSONSchema to validate the structure of the data e.g. the data must contain a name property of minLength 1 and maxLength 100. I then use another validator for business rules e.g. if (x and !y) { throw error)
.
Both with the structural validator and the business logic validator, i'm looking at somewhere around 40 odd rules to validate against. Current thinking was to use the Visitor design pattern (as shown in this question Design Pattern for Data Validation), however, I might be over thinking this, But i was wondering if having 2 validation classes (structural and logical) with over 20 rule validations (in each class) and various other helper functions is too large... part of me is wondering if really each rule (and it's helpers) should be broken out into it's own class... then use the pipeline pattern? or something else entirely.