MCPcopy
hub / github.com/go-playground/validator / StructExcept

Method StructExcept

validator_instance.go:523–525  ·  view source on GitHub ↗

StructExcept validates all fields except the ones passed in. Fields may be provided in a namespaced fashion relative to the struct provided i.e. NestedStruct.Field or NestedArrayField[0].Struct.Name It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error othe

(s interface{}, fields ...string)

Source from the content-addressed store, hash-verified

521// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
522// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
523func (v *Validate) StructExcept(s interface{}, fields ...string) error {
524 return v.StructExceptCtx(context.Background(), s, fields...)
525}
526
527// StructExceptCtx validates all fields except the ones passed in and allows passing of contextual
528// validation information via context.Context

Callers 7

TestNilValidatorFunction · 0.95
TestStructPartialFunction · 0.80
TestInvalidStructFunction · 0.80

Calls 1

StructExceptCtxMethod · 0.95

Tested by 7

TestNilValidatorFunction · 0.76
TestStructPartialFunction · 0.64
TestInvalidStructFunction · 0.64