Skip to content

Add DSL entity validation and transformation#218

Merged
zachdaniel merged 1 commit intoash-project:mainfrom
marot:marot/improve-validation
Sep 25, 2025
Merged

Add DSL entity validation and transformation#218
zachdaniel merged 1 commit intoash-project:mainfrom
marot:marot/improve-validation

Conversation

@marot
Copy link
Copy Markdown
Contributor

@marot marot commented Sep 25, 2025

Overview

Fixes #215

Instead of adding an additional List.wrap, I thought it might be a good idea to perform validation and transformation early on. This PR removes one List.wrap :P

I believe this might cause a slow down of consumers, as we potentially recurse the entity tree repeatedly and don't cache the transformation results.

As a demo, this implements #215. But more validations could be added to catch common misconfigurations. (E.g. to also allow sub-entities without keys, by transforming entities: [@child] to entities: [child_entity_name: [@child]].

Please let me know if this is feasible/wanted - otherwise I'll just add the List.wrap :)

LLM generated commit message

Implements early validation of DSL entity structures to catch configuration errors at compile time rather than runtime. Key improvements:

  • Add validate_and_transform/3 function for recursive entity validation
  • Ensure nested entities are properly formatted as lists
  • Add validation hooks in extension building, section processing, and patches
  • Provide detailed error messages with module and path context
  • Add test coverage for validation scenarios

This prevents invalid DSL configurations from causing runtime errors and provides better developer experience with clear error messages.

Contributor checklist

Leave anything that you believe does not apply unchecked.

  • I accept the AI Policy, or AI was not used in the creation of this PR.
  • Bug fixes include regression tests
  • Chores
  • Documentation changes
  • Features include unit/acceptance tests
  • Refactoring
  • Update dependencies

Implements early validation of DSL entity structures to catch configuration
errors at compile time rather than runtime. Key improvements:

- Add validate_and_transform/3 function for recursive entity validation
- Ensure nested entities are properly formatted as lists
- Add validation hooks in extension building, section processing, and patches
- Provide detailed error messages with module and path context
- Add test coverage for validation scenarios

This prevents invalid DSL configurations from causing runtime errors and
provides better developer experience with clear error messages.
@zachdaniel zachdaniel merged commit 9bb40bc into ash-project:main Sep 25, 2025
21 of 22 checks passed
@zachdaniel
Copy link
Copy Markdown
Contributor

🚀 Thank you for your contribution! 🚀

@marot marot mentioned this pull request Sep 25, 2025
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

It should be possible to create sub-entities of entities without a list

2 participants