mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-10-23 16:08:16 +00:00
bump(go-openapi/validate): d509235108fcf6ab4913d2dcb3a2260c0db2108e
This commit is contained in:
17
vendor/github.com/go-openapi/validate/schema_props.go
generated
vendored
17
vendor/github.com/go-openapi/validate/schema_props.go
generated
vendored
@@ -15,6 +15,7 @@
|
||||
package validate
|
||||
|
||||
import (
|
||||
"log"
|
||||
"reflect"
|
||||
|
||||
"github.com/go-openapi/errors"
|
||||
@@ -80,12 +81,15 @@ func newSchemaPropsValidator(path string, in string, allOf, oneOf, anyOf []spec.
|
||||
|
||||
func (s *schemaPropsValidator) Applies(source interface{}, kind reflect.Kind) bool {
|
||||
r := reflect.TypeOf(source) == specSchemaType
|
||||
// fmt.Printf("schema props validator for %q applies %t for %T (kind: %v)\n", s.Path, r, source, kind)
|
||||
if Debug {
|
||||
log.Printf("schema props validator for %q applies %t for %T (kind: %v)\n", s.Path, r, source, kind)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
func (s *schemaPropsValidator) Validate(data interface{}) *Result {
|
||||
mainResult := new(Result)
|
||||
var firstSuccess *Result
|
||||
if len(s.anyOfValidators) > 0 {
|
||||
var bestFailures *Result
|
||||
succeededOnce := false
|
||||
@@ -94,6 +98,9 @@ func (s *schemaPropsValidator) Validate(data interface{}) *Result {
|
||||
if result.IsValid() {
|
||||
bestFailures = nil
|
||||
succeededOnce = true
|
||||
if firstSuccess == nil {
|
||||
firstSuccess = result
|
||||
}
|
||||
break
|
||||
}
|
||||
if bestFailures == nil || result.MatchCount > bestFailures.MatchCount {
|
||||
@@ -106,11 +113,14 @@ func (s *schemaPropsValidator) Validate(data interface{}) *Result {
|
||||
}
|
||||
if bestFailures != nil {
|
||||
mainResult.Merge(bestFailures)
|
||||
} else if firstSuccess != nil {
|
||||
mainResult.Merge(firstSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
if len(s.oneOfValidators) > 0 {
|
||||
var bestFailures *Result
|
||||
var firstSuccess *Result
|
||||
validated := 0
|
||||
|
||||
for _, oneOfSchema := range s.oneOfValidators {
|
||||
@@ -118,6 +128,9 @@ func (s *schemaPropsValidator) Validate(data interface{}) *Result {
|
||||
if result.IsValid() {
|
||||
validated++
|
||||
bestFailures = nil
|
||||
if firstSuccess == nil {
|
||||
firstSuccess = result
|
||||
}
|
||||
continue
|
||||
}
|
||||
if validated == 0 && (bestFailures == nil || result.MatchCount > bestFailures.MatchCount) {
|
||||
@@ -130,6 +143,8 @@ func (s *schemaPropsValidator) Validate(data interface{}) *Result {
|
||||
if bestFailures != nil {
|
||||
mainResult.Merge(bestFailures)
|
||||
}
|
||||
} else if firstSuccess != nil {
|
||||
mainResult.Merge(firstSuccess)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user