Skip to content

Commit

Permalink
feat: validate nullable (#6928)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathis-m committed Feb 11, 2021
1 parent 7ead9ba commit a2a561e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/utils.js
Expand Up @@ -435,6 +435,7 @@ export const validatePattern = (val, rxPattern) => {
function validateValueBySchema(value, schema, isParamRequired, bypassRequiredCheck, parameterContentMediaType) {
if(!schema) return []
let errors = []
let nullable = schema.get("nullable")
let required = schema.get("required")
let maximum = schema.get("maximum")
let minimum = schema.get("minimum")
Expand All @@ -447,6 +448,10 @@ function validateValueBySchema(value, schema, isParamRequired, bypassRequiredChe
let minItems = schema.get("minItems")
let pattern = schema.get("pattern")

if(nullable && value === null) {
return []
}

/*
If the parameter is required OR the parameter has a value (meaning optional, but filled in)
then we should do our validation routine.
Expand Down

0 comments on commit a2a561e

Please sign in to comment.