0.0.3 • Published 4 months ago

@xqdt/validatorjs v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

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

RuleDescription
required: booleanThe field is mandatory and cannot be left empty.
minLength: numberThe input cannot be less than minLength.
maxLength: numberThe input cannot exceed maxLength.
pattern: regexpThe input must be correspond regexp.
type: "phone" \| "email"The input must be correspond email or number phone
0.0.3

4 months ago

0.0.2

4 months ago

0.0.1

4 months ago