Skip to content

Release 8.8

Choose a tag to compare

@deankarn deankarn released this 16 Nov 18:35
· 84 commits to v8 since this release

What Now?

  • Added new helper method for StructLevel validations "ReportValidationErrors"

Why do I care?

Because you can do the following in a struct level validation

func StructValidationTestStructReturnValidationErrors(v *Validate, structLevel *StructLevel) {

    // TestStructReturnValidationErrors is a triple nested struct
    // see tests for full code
    s := structLevel.CurrentStruct.Interface().(TestStructReturnValidationErrors)

    errs := v.Struct(s.Inner1.Inner2)
    if errs == nil {
        return
    }

    structLevel.ReportValidationErrors("Inner1.", errs.(ValidationErrors))
}