SCHEMA
Validation Methods
.number
.max

Schema - Max (Number)

The .max method is used to validate whether a given value does not exceed a maximum numeric threshold. It ensures that the input value is less than or equal to the specified maximum, providing a way to enforce upper bounds for numeric data.

This method is particularly useful for validating data like maximum prices, ages, or any numeric input requiring an upper limit.


Example

Below is an example of how to use .max to validate whether a value meets the maximum allowed value:

import { schema } from "vkrun"
 
const exampleSchema = schema().number().max(1)
 
const validateA = exampleSchema.validate(1)
const validateB = exampleSchema.validate(2)
 
console.log(validateA) // true
console.log(validateB) // false
Copyright © 2024 MIT by Mario Elvio