Skip to content

๐Ÿ’ โœจ Data class codegen w/ validation & runtime metadata for Dart

License

Notifications You must be signed in to change notification settings

kerberjg/crystallis.dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

26 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

crystallis.dart

๐Ÿ’ โœจ Data class codegen w/ validation & runtime metadata for Dart

dart pub get crystallis

also see crystallis_codegen (pub.dev)

License: MPL 2.0 build example stars
pub package pub score likes

๐Ÿ’™ Use cases

  • Data classes with generated copy/get/set methods
  • Validation of fields and entire objects at runtime
  • Runtime metadata for reflection, serialization, form building, etc

โœจ Features

  • Codegen-based data classes (copyWith, constructors, get/set, equality, etc)
  • Supports both mutable and immutable classes!
  • Per-field validation via annotations (@Min(1), @Max(100), @Regex('^[a-z]+\$'), etc)
  • JSON-compatible de/serialization
    • Per-field customizable serializers via @Serializer(...) annotation
    • serialize method returning Map<String, dynamic>
    • Generates a deserialize constructor
  • Runtime reflection (field metadata available for all annotated classes)
  • copyFrom: copy compatible fields between different data classes
  • Optional per-class deep copying/equality for collections
  • Full-object validation
  • String-named getter/setter methods
  • Optimized for runtime performance and minimal overhead

Coming up next:

  • Support for native/FFI types
  • ByteBuffer serialization/deserialization
  • More validators

๐Ÿ”ฎ Usage Guide

Getting Started

  1. Add crystallis to dependencies and crystallis_generator to dev_dependencies in your pubspec.yaml:

  2. Annotate your data classes with @CrystallisData() and define fields with validation annotations as needed.

  • TODO: Add example here
  1. Run the code generator:
dart run build_runner build
  • Alternatively: use watch for continuous code generation during development:
dart run build_runner watch
  1. Use the generated classes in your application!

Example

/// TODO

Development & Maintenance

TODO


๐Ÿ“„ License

This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.

๐Ÿ”ฅ Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes. Make sure to read the following guidelines before contributing:

๐Ÿ™ Credits & Acknowledgements

Contributors ๐Ÿง‘โ€๐Ÿ’ป๐Ÿ’™๐Ÿ“

This package is developed/maintained by the following rockstars! Your contributions make a difference! ๐Ÿ’–

contributors badge

Sponsors ๐Ÿซถโœจ๐Ÿฅณ

Kind thanks to all our sponsors! Thank you for supporting the Dart/Flutter community, and keeping open source alive! ๐Ÿ’™

sponsors badge


Based on dart_package_template - a high-quality Dart package template with best practices, CI/CD, and more! ๐Ÿ’™โœจ

About

๐Ÿ’ โœจ Data class codegen w/ validation & runtime metadata for Dart

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages