Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/francescovallone/acanthis
Validation library heavily inspired by Zod powered by Dart 🎯
https://github.com/francescovallone/acanthis
dart dart-package object-validator validation-library zod zod-validators
Last synced: about 1 month ago
JSON representation
Validation library heavily inspired by Zod powered by Dart 🎯
- Host: GitHub
- URL: https://github.com/francescovallone/acanthis
- Owner: francescovallone
- License: mit
- Created: 2024-03-05T06:54:37.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-06-28T19:48:48.000Z (6 months ago)
- Last Synced: 2024-06-29T10:49:28.299Z (6 months ago)
- Topics: dart, dart-package, object-validator, validation-library, zod, zod-validators
- Language: Dart
- Homepage: https://pub.dev/packages/acanthis
- Size: 512 KB
- Stars: 13
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Acanthis
Acanthis is a Validation library heavily inspired by [Zod](https://github.com/colinhacks/zod). It is designed to be a simple, and easy to use validation library.
## Features
Acanthis is designed to be composable. Schemas can be composed together to create more complex schemas.
Also Acanthis doesn't require any runtime dependencies, and makes use of a chainable API to create schemas.
## Getting Started
To get started with Acanthis, you can install it using the following command:
```bash
dart pub add acanthis
```## Example
Here is a simple example of how to use Acanthis:
```dart
import 'package:acanthis/acanthis.dart';void main() {
final schema = object({
'name': string().min(3),
'age': number().positive(),
});final result = schema.tryParse({
'name': 'Francesco',
'age': 59,
});/// The result is a AcanthisParseResult object
/// that has the following properties:
/// - success: A boolean that indicates if the parsing was successful or not.
/// - value: The value of the parsing. If the parsing was successful, this will contain the parsed value.
/// - errors: The errors of the parsing. If the parsing was unsuccessful, this will contain the errors of the parsing.if (result.success) {
print('The schema is valid!');
} else {
print('The schema is invalid!');
}
}
```As you can see if you come from a Zod background, the API is very similar and should be familiar to you.
## Contributions
Contributions are welcome! If you want to contribute to Acanthis, you can open a pull request on the [GitHub repository](https://github.com/francescovallone/acanthis/pulls)