zodart 1.1.0
Type-safe schema validation with static type inference and a parse-first design.
Internal README
Code generation
Build runner build
- ZodArt internally uses
Freezedpackage to avoid boilerplate and improve DX. - ZodArt generator is exposed to package users and to generate internal examples.
Files generated by Freezed are not explicitly required by the ZodArt generator, but the codebase depends on them, so they must be built before the ZodArt generator runs.
This causes problems because ZodArt generator is defined in build.yaml for exposure to end users and there's currently no supported way to force build_runner to run builders in a defined order.
To avoid this problem *.freezed.dart should be treated as 'normal files':
- Comment out the build.yaml file
- Build freezed files:
dart run build_runner build --delete-conflicting-outputs - Remove
.dart_toolfolder - Run
dart pub get - Uncomment build.yaml file
- Generate
*.zodart.dartfiles:dart run build_runner watch --delete-conflicting-outputs
Source generator testing
ZodArt uses source_gen package to generate code for annotated classes and to test the generated code source_gen_test package is used.
This package uses golden code files to test the generated code. These files are saved at test/src/code_generation/goldens/.
To regenerate a golden file run: SOURCE_GEN_TEST_UPDATE_GOLDENS=1 dart test <PATH_TO_THE_TEST_FILE>.dart
E.g. SOURCE_GEN_TEST_UPDATE_GOLDENS=1 dart test test/src/code_generation/full_schema_test.dart