VineJS is the fastest Node.js form validation library from the AdonisJS team.
Validation
import vine from "@vinejs/vine";
const schema = vine.compile(
vine.object({
email: vine.string().email(),
password: vine.string().minLength(8),
role: vine.enum(["admin", "user"])
})
);
const data = await schema.validate(input);
Custom Rules
const uniqueEmail = vine.createRule(async (value, _, field) => {
const exists = await db.user.findUnique({ where: { email: value } });
if (exists) field.report("Email taken", "uniqueEmail", field);
});
Key Features
- Fastest Node.js validator
- Compile-once validate-many
- Async rules
- Conditional validation
- TypeScript output types
Need to scrape or monitor web data at scale? Check out my web scraping actors on Apify or email spinov001@gmail.com for custom solutions.
Top comments (0)