File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1919 // SchemaErrorDetailsDisabled disables printing of details about schema errors.
2020 SchemaErrorDetailsDisabled = false
2121
22+ //SchemaFormatValidationDisabled disables validation of schema type formats.
23+ SchemaFormatValidationDisabled = false
24+
2225 errSchema = errors .New ("Input does not match the schema" )
2326
2427 ErrSchemaInputNaN = errors .New ("NaN is not allowed" )
@@ -496,15 +499,19 @@ func (schema *Schema) validate(c context.Context, stack []*Schema) (err error) {
496499 switch format {
497500 case "float" , "double" :
498501 default :
499- return unsupportedFormat (format )
502+ if ! SchemaFormatValidationDisabled {
503+ return unsupportedFormat (format )
504+ }
500505 }
501506 }
502507 case "integer" :
503508 if format := schema .Format ; len (format ) > 0 {
504509 switch format {
505510 case "int32" , "int64" :
506511 default :
507- return unsupportedFormat (format )
512+ if ! SchemaFormatValidationDisabled {
513+ return unsupportedFormat (format )
514+ }
508515 }
509516 }
510517 case "string" :
@@ -520,7 +527,7 @@ func (schema *Schema) validate(c context.Context, stack []*Schema) (err error) {
520527 case "json-pointer" , "relative-json-pointer" :
521528 default :
522529 // Try to check for custom defined formats
523- if _ , ok := SchemaStringFormats [format ]; ! ok {
530+ if _ , ok := SchemaStringFormats [format ]; ! ok && ! SchemaFormatValidationDisabled {
524531 return unsupportedFormat (format )
525532 }
526533 }
You can’t perform that action at this time.
0 commit comments