@@ -428,15 +428,16 @@ function validateValueBySchema(value, schema, requiredByParam, bypassRequiredChe
428
428
let maxItems = schema . get ( "maxItems" )
429
429
let minItems = schema . get ( "minItems" )
430
430
let pattern = schema . get ( "pattern" )
431
+ const isReadOnly = schema . get ( "readOnly" , false )
431
432
432
- const schemaRequiresValue = requiredByParam || requiredBySchema === true
433
+ const isRequired = ! isReadOnly && ( requiredByParam || requiredBySchema === true )
433
434
const hasValue = value !== undefined && value !== null
434
- const isValidEmpty = ! schemaRequiresValue && ! hasValue
435
+ const isValidEmpty = ! isRequired && ! hasValue
435
436
436
437
const needsExplicitConstraintValidation = hasValue && type === "array"
437
438
438
439
const requiresFurtherValidation =
439
- schemaRequiresValue
440
+ isRequired
440
441
|| needsExplicitConstraintValidation
441
442
|| ! isValidEmpty
442
443
@@ -471,7 +472,7 @@ function validateValueBySchema(value, schema, requiredByParam, bypassRequiredChe
471
472
472
473
const passedAnyCheck = allChecks . some ( v => ! ! v )
473
474
474
- if ( schemaRequiresValue && ! passedAnyCheck && ! bypassRequiredCheck ) {
475
+ if ( isRequired && ! passedAnyCheck && ! bypassRequiredCheck ) {
475
476
errors . push ( "Required field is not provided" )
476
477
return errors
477
478
}
@@ -491,7 +492,8 @@ function validateValueBySchema(value, schema, requiredByParam, bypassRequiredChe
491
492
}
492
493
if ( schema && schema . has ( "required" ) && isFunc ( requiredBySchema . isList ) && requiredBySchema . isList ( ) ) {
493
494
requiredBySchema . forEach ( key => {
494
- if ( objectVal [ key ] === undefined ) {
495
+ const propIsReadOnly = schema . getIn ( [ "properties" , key , "readOnly" ] , false )
496
+ if ( objectVal [ key ] === undefined && ! propIsReadOnly ) {
495
497
errors . push ( { propKey : key , error : "Required property not found" } )
496
498
}
497
499
} )
0 commit comments