Releases: debuggers-dev/mobikit-typescript
Releases · debuggers-dev/mobikit-typescript
Mobikit TypeScript v1.0.2
Mobikit TypeScript v1.0.2
Mobikit TypeScript is a powerful validation library for TypeScript applications, providing a comprehensive set of validation rules for form inputs and data structures.
Features
- 🚀 TypeScript Support: Built from the ground up with TypeScript
- 🔍 Extensive Validation Rules: Over 20 built-in validation rules
- 🌐 Internationalization: Support for multiple languages
- ⚡ Async Validation: Support for asynchronous validation rules
- 🧩 Extensible: Easy to add custom validation rules
Validation Rules
This release includes the following validation rules:
required: Ensures a field is not emptymin: Validates minimum numeric valuesmax: Validates maximum numeric valuesemail: Validates email addressesregex: Validates against regular expressionssame: Ensures two fields have the same valuenumeric: Ensures a field contains only numbersmaxLen: Validates maximum string lengthminLen: Validates minimum string lengthrequired_if: Conditionally requires a field based on another field's valuerequired_unless: Conditionally requires a field unless another field has a specific valuerequired_with: Requires a field when another specified field is presentrequired_without: Requires a field when another specified field is not presentrequired_with_all: Requires a field when all other specified fields are presentrequired_without_all: Requires a field when all other specified fields are not presentuppercase: Ensures a field contains only uppercase characterslowercase: Ensures a field contains only lowercase charactersjson: Validates that a field contains valid JSONalpha: Ensures a field contains only alphabetic charactersin: Validates that a field's value is in a given listnot_in: Validates that a field's value is not in a given list
Installation
npm install mobikit-typescriptor
yarn add mobikit-typescriptBasic Usage
import { Validator } from 'mobikit-typescript';
const validator = new Validator('en');
const data = {
username: 'test',
email: 'invalid-email',
age: '25'
};
const rules = {
username: {
required: { value: true, message: 'Username is required.' },
minLen: { value: 5, message: 'Username must have at least 5 characters.' }
},
email: {
required: { value: true, message: 'Email is required.' },
email: { value: true, message: 'Please enter a valid email address.' }
},
age: {
numeric: { value: true, message: 'Age must be a number.' }
}
};
async function validate() {
const errors = await validator.validate(data, rules);
if (errors) {
console.log(errors);
} else {
console.log('Validation passed!');
}
}
validate();Breaking Changes
None (initial release)
Bug Fixes
None (initial release)
Future Plans
- Add more validation rules
- Improve error messages
- Add more language support
- Enhance documentation