Input validation for javascript.
Install Input Refacter
to your project.
pnpm install input-refacter
Simple login validation example.
import refacter from "input-refacter";
// define validation schema
const schema = {
name: refacter("username", "example", {
min: 4,
small: true
}),
password: refacter("password", "Example123@", {
min: 4,
small: true,
special: true
})
};
if (schema.name.valid && schema.password.valid) {
console.log("You are great!");
} else {
console.log(.name.first);
console.log(.password.first);
}