MCPcopy
hub / github.com/danielgtaylor/huma / validateOneOf

Function validateOneOf

validate.go:303–319  ·  view source on GitHub ↗
(r Registry, s *Schema, path *PathBuffer, mode ValidateMode, v any, res *ValidateResult)

Source from the content-addressed store, hash-verified

301}
302
303func validateOneOf(r Registry, s *Schema, path *PathBuffer, mode ValidateMode, v any, res *ValidateResult) {
304 found := false
305 subRes := &ValidateResult{}
306 for _, sub := range s.OneOf {
307 Validate(r, sub, path, mode, v, subRes)
308 if len(subRes.Errors) == 0 {
309 if found {
310 res.Add(path, v, "expected value to match exactly one schema but matched multiple")
311 }
312 found = true
313 }
314 subRes.Reset()
315 }
316 if !found {
317 res.Add(path, v, validation.MsgExpectedMatchExactlyOneSchema)
318 }
319}
320
321func validateAnyOf(r Registry, s *Schema, path *PathBuffer, mode ValidateMode, v any, res *ValidateResult) {
322 matches := 0

Callers 2

validateDiscriminatorFunction · 0.85
ValidateFunction · 0.85

Calls 3

ResetMethod · 0.95
ValidateFunction · 0.85
AddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…