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

Method StructPartial

validator_instance.go:437–439  ·  view source on GitHub ↗

StructPartial validates the fields passed in only, ignoring all others. Fields may be provided in a namespaced fashion relative to the struct provided eg. NestedStruct.Field or NestedArrayField[0].Struct.Name It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as

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

Source from the content-addressed store, hash-verified

435// It returns InvalidValidationError for bad values passed in and nil or ValidationErrors as error otherwise.
436// You will need to assert the error if it's not nil eg. err.(validator.ValidationErrors) to access the array of errors.
437func (v *Validate) StructPartial(s interface{}, fields ...string) error {
438 return v.StructPartialCtx(context.Background(), s, fields...)
439}
440
441// StructPartialCtx validates the fields passed in only, ignoring all others and allows passing of contextual
442// validation information via context.Context

Calls 1

StructPartialCtxMethod · 0.95

Tested by 7

TestNilValidatorFunction · 0.76
TestStructPartialFunction · 0.64
TestInvalidStructFunction · 0.64