import { Email, MaxLength, MinLength, Pattern, validate } from '@deepkit/type'; type Username = string & MinLength<3> & MaxLength<20> & Pattern<'^[a-zA-Z0-9]+$'>; class User { email: Email = ''; username: Username = ''; } const errors = validate<User>({ email: 'peter@example.com', username: 'pet' }); console.log(errors); // [{ path: 'username', message: '...' }]