visit our docs site: Bshg Docs
Welcome to @bshg/validation
, a versatile TypeScript library crafted for seamless data validation within your projects.
Whether you’re working on a front-end or back-end application, this library empowers you to validate data in a
declarative manner, ensuring your objects align with your expectations.
Designed with simplicity and efficiency in mind, @bshg/validation
streamlines the validation process, making it a
reliable choice for your projects. It offers extensive customization options, enabling you to tailor validation rules
and error messages to fit your specific requirements with ease.
This library is lightweight and has no external dependencies, ensuring fast load times and minimal impact on your
application’s performance. Whether you’re building a web application, API, or mobile app, you can rely on
@bshg/validation
to handle validation consistently across platforms.
@bshg/validation
?@bshg/validation
is designed to be straightforward and efficient, making
implementation easy while maintaining high performance.@bshg/validation
ensures fast load times and minimal impact on
performance.@bshg/validation
in both frontend and backend projects, and seamlessly share validation
logic between them. This makes displaying server-side validation results on the client-side straightforward and
requires no extra code.Let’s dive into the details of how to use this library effectively.
Install @bshg/validation
via npm:
npm install @bshg/validation
yarn add @bshg/validation
export class User {
username: string;
password: string;
fullName: string;
age: number;
email: string;
phone: string;
}
v
symbol, which contains all the library methods you can use:
import { v } from '@bshg/validation';
User
type:
import { v } from '@bshg/validation';
const item = new User();
const validator = v.validator<User>({
items: {
username: v.string().required().alpha(),
password: v.string().required().min(8),
fullName: v.string().required(),
email: v.string().required().email(),
phone: v.string().required().phone(),
age: v.number().positive(),
}
}).init(() => item);