ts-validation-lite
v2.0.19
Published
Lightweight, type-safe validation utility library for web developers
Maintainers
Readme
ts-validation-lite
Lightweight, type-safe validation utility library for web developers.
Installation
npm install ts-validation-liteUsage
import { Injectable } from '@angular/core';
import { ValidationUtils } from 'ts-validation-lite';
@Injectable({ providedIn: 'root' })
export class MyService {
constructor(private val: ValidationUtils) { }
myMethod(): void {
this.val.isEmail('[email protected]'); // true
this.val.isUrl('https://google.com'); // true
this.val.isPhone('+1234567890'); // true
this.val.isPostalCode('12345'); // true
this.val.isStrongPassword('Test123!'); // {valid: true, score: 4}
}
}Methods
| Method | Description | Example |
|--------|-------------|---------|
| isEmail | Validate email | '[email protected]' → true |
| isUrl | Validate URL | 'https://google.com' → true |
| isPhone | Validate phone | '+1234567890' → true |
| isPostalCode | Validate postal code | '12345' → true |
| isStrongPassword | Check password strength | 'Test123!' → {valid: true, score: 4} |
License
MIT
