0.0.3 • Published 8 months ago
@xqdt/validatorjs v0.0.3
ValidatorJS
Installation and Usage
HTML
<form>
  <input id="name" type="text" />
</form>JS
import { validate } from "@xqdt/validatorjs";
const form = document.querySelector("form");
validate(form, {
  name: {
    required: true,
    minLength: 8,
    maxLength: 100,
    pattern: /^[a-zA-Z0-9]+@[a-zA-Z]+\.[a-zA-Z]+$/,
  },
});Validators
| Rule | Description | 
|---|---|
required: boolean | The field is mandatory and cannot be left empty. | 
minLength: number | The input cannot be less than minLength. | 
maxLength: number | The input cannot exceed maxLength. | 
pattern: regexp | The input must be correspond regexp. | 
type: "phone" \| "email" | The input must be correspond email or number phone |