AddError adds a validation error to the target. It "flattens" validation errors so that the recorded errors are never ValidationErrors themselves.
(def Expression, err error)
| 175 | // AddError adds a validation error to the target. It "flattens" validation |
| 176 | // errors so that the recorded errors are never ValidationErrors themselves. |
| 177 | func (verr *ValidationErrors) AddError(def Expression, err error) { |
| 178 | var v *ValidationErrors |
| 179 | if errors.As(err, &v) { |
| 180 | verr.Errors = append(verr.Errors, v.Errors...) |
| 181 | verr.Expressions = append(verr.Expressions, v.Expressions...) |
| 182 | return |
| 183 | } |
| 184 | verr.Errors = append(verr.Errors, err) |
| 185 | verr.Expressions = append(verr.Expressions, def) |
| 186 | } |
| 187 | |
| 188 | // runSet executes the DSL for all expressions in the given set. The expression |
| 189 | // DSLs may append to the set as they execute. |
no outgoing calls