这是indexloc提供的服务,不要输入任何密码
Skip to content

Support for conditions on type aliases #928

@SimonCockx

Description

@SimonCockx

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestsubject: code generationThis issue is about code generation

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions