Skip to content

Commit

Permalink
add description and examples for exclusiveMinimum keyword
Browse files Browse the repository at this point in the history
  • Loading branch information
AgniveshChaubey committed Feb 18, 2024
1 parent 828b446 commit 26a9eef
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions content/2020-12/validation/exclusiveMinimum.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,69 @@ related:
- vocabulary: validation
keyword: multipleOf
---

The `exclusiveMinimum` keyword is used to set an exclusive lower limit on numeric instances. It specifies that the numeric value being validated must be strictly greater than (not equal to) the provided minimum value.

* Applies only to number data types (integers and floats).
* Validation succeeds if the number is strictly greater than the specified `exclusiveMinimum`.

## Examples

{{<schema `Schema defining exclusive lower limit of 5 on numeric values`>}}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "number",
"exclusiveMinimum": 5
}
{{</schema>}}

{{<instance-fail `An instance with numeric value less than 5 is invalid`>}}
3
{{</instance-fail>}}

{{<instance-pass `An instance with numeric value greater than 5 is valid`>}}
9.5
{{</instance-pass>}}

{{<instance-fail `An instance with numeric value equal to 5 is invalid`>}}
5
{{</instance-fail>}}

{{<schema ` Schema allowing either a string value or a numeric value with an exclusive lower limit of 10`>}}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [ "string", "number" ],
"exclusiveMinimum": 10
}
{{</schema>}}

{{<instance-pass `An instance with a numeric value greater than 10 is valid`>}}
15
{{</instance-pass>}}

{{<instance-fail `An instance with a boolean datatype is invalid`>}}
false
{{</instance-fail>}}

{{<instance-pass `An instance with a string value is valid`>}}
"Hello World!"
{{</instance-pass>}}

{{<schema `Schema with both 'minimum' and 'exclusiveMinimum' keywords`>}}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "number",
"exclusiveMinimum": 10,
"minimum": 5
}
{{</schema>}}

{{<instance-pass `An instance with numeric value greater than 10 is valid`>}}
15
{{</instance-pass>}}

{{<instance-fail `An instance with numeric value less than or equal to 10 is invalid`>}}
9.5
{{</instance-fail>}}

* _**Note:** Here, the `exclusiveMinimum` takes precedence, even though `minimum` is 5. Only numbers greater than 10 are valid._

0 comments on commit 26a9eef

Please sign in to comment.