https://github.com/daniel-samson/dilo
A form / object validation library written for Deno
https://github.com/daniel-samson/dilo
deno validation validation-library
Last synced: 5 months ago
JSON representation
A form / object validation library written for Deno
- Host: GitHub
- URL: https://github.com/daniel-samson/dilo
- Owner: daniel-samson
- Created: 2024-11-12T23:45:35.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-09T17:41:23.000Z (over 1 year ago)
- Last Synced: 2025-02-09T18:31:17.216Z (over 1 year ago)
- Topics: deno, validation, validation-library
- Language: TypeScript
- Homepage: https://jsr.io/@danielsamson/dilo
- Size: 115 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dilo
A validation library for deno. The name is short for "Dilophosaurus". It is
essentially a port of laravel's validation library.
## Project Status
This project is currently in active development. It follows the practices of
[Semantic Versioning](https://semver.org/).
[](https://github.com/daniel-samson/dilo/actions/workflows/deno.yml)
[](https://codecov.io/gh/daniel-samson/dilo)
[](https://jsr.io/@danielsamson/dilo)
[](https://jsr.io/@danielsamson/dilo>)
## Usage
```ts
import { Dilo } from "@danielsamson/dilo";
const rules = {
foo: "required|numeric",
bar: "sometimes|string",
baz: "nullable|boolean",
};
const request = Dilo.make(rules);
const errors = request.validate({ foo: "1", bar: "bar", baz: true });
if (errors) {
for (const field of Object.keys(errors)) {
console.log(field, errors[field]);
}
}
```
Output:
```shell
foo [ "foo must be a numeric value" ]
```
## Documentation
You can find the documentation for the latest version at
[read the docs](https://dilo.readthedocs.io/en/latest/).
## Contributing
### Setting up Git Hooks
After cloning the repository, run the following command to set up Git hooks:
```bash
./setup-hooks.sh
```