SCHEMA
Validation Methods
.string
.email

Schema - Email (String)

The .email method is used to validate whether a given string is a properly formatted email address. It ensures that the input follows the standard email structure, including an "@" symbol and a valid domain.

This method is particularly useful for user input validation, such as email fields in registration forms, login systems, or any scenario where an email address needs to be verified.


Example

Below is an example of how to use .email to validate whether a value is a valid email:

import { schema } from "vkrun"
 
const exampleSchema = schema().string().email()
 
const validateA = exampleSchema.validate("any_email@mail.com")
const validateB = exampleSchema.validate("any_email@mail")
 
console.log(validateA) // true
console.log(validateB) // false
Copyright © 2024 MIT by Mario Elvio