A zero-dependency, ultra-lightweight JavaScript validation library with built-in auto-formatters. Dates, times, CNIC, passwords, and formsβall in one file.
cdn.jsdelivr.net/gh/sahirpunjwani/Valifyjs@1.1.5/index.js
<!-- via CDN script tag -->
<script src="https://cdn.jsdelivr.net/gh/sahirpunjwani/Valifyjs@1.1.5/index.js"></script>
<!-- access globally via window.Valify -->
<script>
// Validations
Valify.cnic("42101-1234567-1"); // returns true
// Formatters
Valify.format.cnic("4210112345671"); // returns "42101-1234567-1"
</script>
in one ecosystem
unminified file size
third-party dependencies
free open-source license
What's Inside
Type directly into the fields below. The library will auto-format your string layout and validate it in real time (Green = Valid, Red = Invalid).
Pattern validation for Pakistani Identity Cards. Automatically introduces hyphen boundaries dynamically as you enter values.
Flexible evaluation supporting formats. Re-structures your local code input pattern into a standardized +92 format structure instantly.
Evaluate form pickers down to the chronological timeline. Ensures your reservation start date starts before an ending date.
Enforce elite validation policies requiring at least 8 elements comprising uppercase letters, lowercase, numbers, and symbols.
Native mathematical parsing powered by the Luhn Algorithm checksum. Spaces out input digits into neat chunks of four elements.
Validates strict 24-hour schedules (HH:MM / HH:MM:SS) alongside standard 12-hour AM/PM string formats seamlessly.
Code Examples
Clean snippets showcasing implementation options inside forms or application scopes.
// Validating standard required text strings and email inputs
if (!Valify.required(emailInput)) {
showError("Field is mandatory");
}
if (!Valify.email(emailInput)) {
showError("Please enter a structured, authentic email address");
}
// Length properties
Valify.minLength("hello", 3); // true
Valify.maxLength("hello", 3); // false
// Validating chronologies and ranges
const checkIn = "2026-06-01";
const checkOut = "2026-06-05";
if (!Valify.dateRange(checkIn, checkOut)) {
console.error("Check-out cannot occur before check-in date!");
}
// Check relative bounds
Valify.futureDate("2030-01-01"); // true
Valify.pastDate("1999-12-31"); // true
// Specialized card structures and localized checks
const localCnic = "42101-1234567-1";
Valify.cnic(localCnic); // true
// Verify phone structures
Valify.phone("+923001234567"); // true
// Evaluate card formats via the Luhn Algorithm before API checkout
if (Valify.creditCard("49927398716")) {
proceedToCheckout();
}
Reference
An extensive dictionary of functions, matching inputs, and returned outputs.
| Method Name | Arguments Taken | Description Check | Returns |
|---|---|---|---|
.required(val) |
value (any) |
Verifies field is not undefined, null, or empty whitespace. | boolean |
.email(val) |
value (string) |
Matches input text structure against verified email patterns. | boolean |
.url(val) |
value (string) |
Safely parses string against browser native URL constructors. | boolean |
.cnic(val) |
value (string) |
Checks for exact Pakistani format: 55555-5555555-5. | boolean |
.phone(val) |
value (string) |
Evaluates valid local parameters and global international formats. | boolean |
.number(val) |
value (num) |
Confirms variable is structural digits and excludes NaN loops. | boolean |
.range(val, min, max) |
val, min, max (num) |
Ensures input number values are sequentially bounded. | boolean |
.date(val) |
value (string/date) |
Validates if string translates into standard browser calendar records. | boolean |
.futureDate(val) |
value (string/date) |
Verifies timestamp occurs past the current local clock tick. | boolean |
.pastDate(val) |
value (string/date) |
Verifies input target represents historical timestamps. | boolean |
.dateRange(start, end) |
start, end (string) |
Confirms start picker is chronological before the ending date. | boolean |
.time24(val) |
value (string) |
Tests 24-hour notations up to 23:59 or 23:59:00. | boolean |
.time12(val) |
value (string) |
Requires structural standard AM/PM indicators (e.g. 11:30 AM). | boolean |
.strongPassword(val) |
value (string) |
Checks min 8 chars with 1 upper, 1 lower, 1 digit, 1 symbol. | boolean |
.creditCard(val) |
value (string/num) |
Evaluates strict mathematical legitimacy via Luhn algorithms. | boolean |
.format.cnic(val) |
value (string) |
Auto-formats string into structured 55555-5555555-5 blocks. | string |
.format.phone(val) |
value (string) |
Auto-formats structural pak numbers to standardized +92 code spans. | string |
.format.creditCard(val) |
value (string) |
Splits numeric strings automatically in groups of 4 values. | string |
Documentation
Deep-dive structural architecture notes explaining regex optimizations, formatting patterns, and pipeline processing hooks inside Valify.js.
Valify.js runs entirely on declarative validation models. Instead of initializing complex class schemas or long chain-link abstractions, it returns pure, deterministic booleans directly to programmatic check steps.
The built-in matchers (like CNIC and Phone variables) are pre-compiled internally. This isolates evaluation pipelines from regex engine generation overhead during repetitive keydown event listeners.
5-7-1 string lengths.Valify keeps a clean separation between string-formatting layers and true state verification logic to prevent user confusion.
Temporal validation goes beyond simple string matching by processing inputs directly through browser-native Date.parse() constructors.