Closed PMcca closed 1 year ago
At the moment, there are no default rules when validating structs. I'm also not sure whether that would be a good idea, since different projects, maybe even nested struct layers, might need different default rules. I would say that it should be up to you to update the validation methods when your structs change.
Sorry if this is a dumb question, but I've not found a way of doing this.
I have a struct like:
I would like to ensure that
Foo
(and any subsequent structs likeBar
) do not have any empty fields. i.e. something like:However, from examples it seems the only way to do this is to implement the
Validatable
interface for all structs you want to check. The above code excerpt will not return an error becauseFoo
does not implement theValidatable
interface.Is there any "default" way, like the one linked above, which will be able to iterate over each field and check if the fields are non-empty? Otherwise it seems if new fields are added, the validator method(s) needs to be updated.