-
-
Notifications
You must be signed in to change notification settings - Fork 130
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 min and max length for a string property in CTO #643
Support min and max length for a string property in CTO #643
Comments
We should only use decorators for things that are external/opaque to Concerto. In this case we'd be using these facets to validate string properties so I think the meta model should be extended to support this. 'length' seems like a good name, and we could implement it similar to range for numbers, with an optional lower and upper bound, or we could add 'maxLength' and 'minLength' as explicit meta properties. |
The
We could also make lower and upper bounds optional (like with
Also note that with concerto/packages/concerto-core/lib/introspect/numbervalidator.js Lines 92 to 102 in 9009e82
|
As discussed on today's working group call, we should give this modifier precedence over the regex modifier if both are used. Validating against |
For translating these field constraints/modifiers into things such as OpenAPI, would using common labels such as those in JSON schema be practical? For example, as @dselman suggested, -Steven |
@f5th-dimensional |
Please ensure that the latest metamodel is publish to the public model repo: https://models.accordproject.org/concerto/[email protected] |
Feature Request 🛍️
Currently, we have the option to use regex to enforce string length, but this can be an expensive operation. Considering that major data modeling tools support string length validators, it would be beneficial to have this functionality in Concerto as well.
Possible Solution
Solution 1: Introduce a new decorator to support this feature.
Solution 2: Enhance CTO property definition to incorporate this feature.
range[1,10]
to declare a valid range for numeric properties. We can leverage this meta property for strings as well, where it would represent the length of a string.length
to support this feature.Context
We are in the process of replacing our data models with Concerto models. Some of the string properties in our data model have string length configurations/validators, and it would be great to have a similar setting in Concerto.
The text was updated successfully, but these errors were encountered: