Open nathanslaughtergs opened 7 years ago
Thanks, and great idea - it would have to check the child schema too, and be a bit careful about the security, i.e. not just include the text of the regex directly into the Go code since that could lead to code injection, but relatively straightforward to do.
I don't know whether each struct should have a Validate()
method which calls a method for each field, to validate the object graph (fields and their fields etc.) e.g. ValidateName()
, and the Validate()
method should return a map of field names to a slice of errors: map[string]error
?
I'm working flat out on something else at the moment, but if you want to have a stab at it, that would be ace.
Nice work putting this together. How do you think it would best support patterns in json schema? There could be a ".Validate() error" method which that would run through the regexen supplied as patterns in schema.