[GO] Add assert constraints checks for complex types in the model template (#18654)

* [GO] Add assert constraints checks for complex types in the model template

* [GO] Update samples

* [GO] revert AssertRecurseInterface naming
This commit is contained in:
Aviv Levitski
2024-05-15 11:59:35 +03:00
committed by GitHub
parent a9b1f93d65
commit affb6bc1f7
10 changed files with 139 additions and 0 deletions

View File

@@ -64,5 +64,13 @@ func AssertUserRequired(obj User) error {
// AssertUserConstraints checks if the values respects the defined constraints
func AssertUserConstraints(obj User) error {
if obj.DeepSliceModel != nil {
if err := AssertRecurseInterfaceRequired(*obj.DeepSliceModel, AssertTagConstraints); err != nil {
return err
}
}
if err := AssertRecurseInterfaceRequired(obj.DeepSliceMap, AssertAnObjectConstraints); err != nil {
return err
}
return nil
}