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 complex objects as decorator argument values #918

Open
dselman opened this issue Oct 10, 2024 · 0 comments
Open

Support complex objects as decorator argument values #918

dselman opened this issue Oct 10, 2024 · 0 comments

Comments

@dselman
Copy link
Contributor

dselman commented Oct 10, 2024

Feature Request ๐Ÿ›๏ธ

Currently decorator arguments are limited to:

  • String
  • Number
  • Boolean
  • Type reference

It would be useful to support a stringified arbitrary object as a decorator argument value.

Use Case

Automated systems creating models and storing complex decorator arguments on the model.

Possible Solution

namespace [email protected]

concept TextFormat extends Decorator {
   o String font
   o Integer fontSize
   o Boolean isBold optional
   o Boolean isItalic optonal
}

@TextFormat({"font": "arial", "fontSize" : 12, "isBold" : true})
concept TextField {
    o String value
}

Context

When decorator arguments become complex they are hard to read, because they are based on positional arguments.

Detailed Description

We would have to extend the CTO grammar to support JSON objects within decorator arguments, marshalling them into a new type of DecoratorLiteral, or extending the DecoratorStringLiteral to carry the JSON value as a string.

Extend the logic that validates decorator arguments to check the structure of the JSON conforms to the related decorator definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant