Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for conditions on type aliases #928

Open
SimonCockx opened this issue Feb 18, 2025 · 1 comment
Open

Support for conditions on type aliases #928

SimonCockx opened this issue Feb 18, 2025 · 1 comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request subject: code generation This issue is about code generation

Comments

@SimonCockx
Copy link
Contributor

SimonCockx commented Feb 18, 2025

Based on this contribution which adds syntactical support for conditions on type aliases, we should enhance our validator generator so it properly uses those conditions.

Example: let's say we want to define a string type that must have an odd number of characters and consists out of a specific configurable amount of words:

typeAlias MyAlias(numberOfWords int):
  OtherAlias(true)

  condition MustHaveSpecificNumberOfWords:
    GetNumberOfWords = numberOfWords

typeAlias OtherAlias(isOddLength boolean):
  string

  condition LengthIsOdd:
    if isOddLength
    then CheckLengthIsOdd

type Foo:
  attr1 MyAlias(2) (1..1)
  attr2 MyAlias(3) (0..*)

This should:

  • generate condition classes for the conditions on MyAlias and OtherAlias,
  • call these conditions in the type format validator of Foo.

Note that these alias conditions must be parameterized accordingly, so they will not implement the Validator<String> interface.

Prerequisites:

@SimonCockx SimonCockx added enhancement New feature or request subject: code generation This issue is about code generation documentation Improvements or additions to documentation labels Feb 18, 2025
@SimonCockx
Copy link
Contributor Author

We should also add documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request subject: code generation This issue is about code generation
Projects
None yet
Development

No branches or pull requests

1 participant