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 19
19
// SchemaErrorDetailsDisabled disables printing of details about schema errors.
20
20
SchemaErrorDetailsDisabled = false
21
21
22
+ //SchemaFormatValidationDisabled disables validation of schema type formats.
23
+ SchemaFormatValidationDisabled = false
24
+
22
25
errSchema = errors .New ("Input does not match the schema" )
23
26
24
27
ErrSchemaInputNaN = errors .New ("NaN is not allowed" )
@@ -496,15 +499,19 @@ func (schema *Schema) validate(c context.Context, stack []*Schema) (err error) {
496
499
switch format {
497
500
case "float" , "double" :
498
501
default :
499
- return unsupportedFormat (format )
502
+ if ! SchemaFormatValidationDisabled {
503
+ return unsupportedFormat (format )
504
+ }
500
505
}
501
506
}
502
507
case "integer" :
503
508
if format := schema .Format ; len (format ) > 0 {
504
509
switch format {
505
510
case "int32" , "int64" :
506
511
default :
507
- return unsupportedFormat (format )
512
+ if ! SchemaFormatValidationDisabled {
513
+ return unsupportedFormat (format )
514
+ }
508
515
}
509
516
}
510
517
case "string" :
@@ -520,7 +527,7 @@ func (schema *Schema) validate(c context.Context, stack []*Schema) (err error) {
520
527
case "json-pointer" , "relative-json-pointer" :
521
528
default :
522
529
// Try to check for custom defined formats
523
- if _ , ok := SchemaStringFormats [format ]; ! ok {
530
+ if _ , ok := SchemaStringFormats [format ]; ! ok && ! SchemaFormatValidationDisabled {
524
531
return unsupportedFormat (format )
525
532
}
526
533
}
You can’t perform that action at this time.
0 commit comments