Skip to content

Commit

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

The `maximum` keyword is used to set the upper limit on numeric instances. It specifies that the numeric value being validated must be less than or equal to the provided maximum value.

* Applies only to number data types (integers and floats).
* Validation succeeds if the number is less than or equal to the specified `maximum`.

## Examples

{{<schema `Schema defining the upper limit of 10 on numeric values`>}}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "number",
"maximum": 10
}
{{</schema>}}

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

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

{{<instance-pass `An instance with a numeric value equal to 10 is valid`>}}
10
{{</instance-pass>}}

{{<schema ` Schema allowing either a boolean value or a numeric value with an upper limit of 20`>}}
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": [ "boolean", "number" ],
"maximum": 20
}
{{</schema>}}

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

{{<instance-fail `An instance with a string datatype is invalid`>}}
"Hello World!"
{{</instance-fail>}}

{{<instance-pass `An instance with a boolean value is valid`>}}
true
{{</instance-pass>}}

0 comments on commit e104106

Please sign in to comment.