https://github.com/sveltecult/fluent-formdata-validator
A versatile form data validation library offering a fluent API to ensure data integrity and consistency in web applications.
https://github.com/sveltecult/fluent-formdata-validator
form-data form-validation validation validator
Last synced: 2 months ago
JSON representation
A versatile form data validation library offering a fluent API to ensure data integrity and consistency in web applications.
- Host: GitHub
- URL: https://github.com/sveltecult/fluent-formdata-validator
- Owner: sveltecult
- License: mit
- Created: 2024-03-17T23:50:39.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-28T23:59:37.000Z (almost 2 years ago)
- Last Synced: 2025-03-10T18:12:59.594Z (about 1 year ago)
- Topics: form-data, form-validation, validation, validator
- Language: TypeScript
- Homepage: https://fluent-formdata-validator.sveltecult.com
- Size: 46.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Fluent FormData Validator
A versatile form data validation library offering a fluent API to ensure data integrity and consistency in web applications. Please note that this project is currently a work in progress and undergoing active development.
## Features
- Fluent validation API
- Supports basic input types: boolean, date, number and string.
- Array validation using `[]` and `.*` notations
- Customizable validation rules
- Framework agnostic
- With 40+ [available rules](https://fluent-formdata-validator.sveltecult.com)
## Installation
To install, use your preferred package manager:
```bash
npm install fluent-formdata-validator
```
## Getting Started
Detailed instructions on getting started and list of available validation rules can be found in the [documentation](https://fluent-formdata-validator.sveltecult.com).
## Basic Usage
```typescript
import { Rule, Validation } from '@sveltecult/formdata-validator';
/** @type {import('./$types').Actions} */
export const actions = {
default: async ({ request }) => {
const formData = await request.formData();
const validation = new Validation(formData, {
email: Rule.string().required().email(),
password: Rule.string().required().minLength(8).confirmed()
});
const errors = await validation.errors();
if (errors.any() === true) {
console.log(errors.all());
}
}
};
```
## Writing Custom Validation
This library allows writing custom validation logic using the `.custom()` rule for scenarios where standard validation rules don't meet specific requirements, such as database-related checks. [Click here](https://fluent-formdata-validator.sveltecult.com/guides/custom) to learn more about how to create your own custom validation.
## License
[](https://opensource.org/licenses/MIT)
This library is licensed under the MIT License.