Schema - Min (Number)
The .min
method is used to validate whether a given value meets a minimum numeric threshold. It ensures that the input value is greater than or equal to the specified minimum, providing a way to enforce lower bounds for numeric data.
This method is particularly useful for validating data like minimum prices, ages, or any numeric input requiring a lower limit.
Example
Below is an example of how to use .min
to validate whether a value meets the minimum required value:
import { schema } from "vkrun"
const exampleSchema = schema().number().min(1)
const validateA = exampleSchema.validate(1)
const validateB = exampleSchema.validate(0)
console.log(validateA) // true
console.log(validateB) // false