Schema - MinWord (String)
The .minWord
method is used to validate whether a given string contains at least a specified number of words. This method ensures that the input meets the minimum word count requirement, making it particularly useful for fields like names, comments, or any input where word count is significant.
Example
Below is an example of how to use .minWord
to validate whether a string contains the required number of words:
import { schema } from "vkrun"
const exampleSchema = schema().string().minWord(2)
const validateA = exampleSchema.validate("one two")
const validateB = exampleSchema.validate("one")
console.log(validateA) // true
console.log(validateB) // false