DEV Community

Alex Spinov
Alex Spinov

Posted on

VineJS Has a Free API That Most Developers Dont Know About

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);
Enter fullscreen mode Exit fullscreen mode

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);
});
Enter fullscreen mode Exit fullscreen mode

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)