This project showcases the usage of TypeScript decorators for property validation within classes. Various decorators are applied to class properties to enforce validation rules such as length, data type, format, and more.
-
Clone the repository:
git clone https://github.com/noone313/Validator_v2.git
cd Validator_v2
npm install
import { IsLength, IsNumber } from './validators';
class Person {
@IsLength(2, 20)
firstName: string = "";
@IsNumber()
age: number = 0;
}
const person = new Person();
person.firstName = "John"; // Valid
person.age = 30; // Valid