Giter Site home page Giter Site logo

Comments (6)

dselman avatar dselman commented on September 27, 2024 2

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.

from concerto.

mttrbrts avatar mttrbrts commented on September 27, 2024 1

The range property modifier syntax includes an = so we should mirror that. e.g.

concept Contact {
   o String firstName length=[0,100]
}

We could also make lower and upper bounds optional (like with range), e.g.

concept Contact {
   o String firstName length=[1,] // only non-empty strings are allowed
   o String lastName length=[,100] // syntactic sugar for [0,100]
}

Also note that with range, the upper-bound is inclusive, i.e. range=[3,10] means 3 >= x <= 10

validate(identifier, value) {
if(value !== null) {
if(this.lowerBound !== null && value < this.lowerBound) {
this.reportError(identifier, `Value ${value} is outside lower bound ${this.lowerBound}`);
}
if(this.upperBound !== null && value > this.upperBound) {
this.reportError(identifier, `Value ${value} is outside upper bound ${this.upperBound}`);
}
}
}

from concerto.

mttrbrts avatar mttrbrts commented on September 27, 2024

As discussed on today's working group call, we should give this modifier precedence over the regex modifier if both are used.

Validating against length is the simpler, faster, and less-general operation.

from concerto.

f5th-dimensional avatar f5th-dimensional commented on September 27, 2024

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, maxLength and minLength to describe character limits in a string, or minimum maximum to describe the range of possible values. Also, should distinguishing between inclusive and exclusive range values be considered, such as in the use of exclusiveMinimum and exclusiveMaximum?

-Steven

from concerto.

mttrbrts avatar mttrbrts commented on September 27, 2024

For translating these field constraints/modifiers into things such as OpenAPI, would using common labels such as those in JSON schema be practical?

@f5th-dimensional
Are you suggesting using the same keywords from OpenAPI in Concerto, or just declaring an equivalence when converting to/from OpenAPI.

from concerto.

dselman avatar dselman commented on September 27, 2024

Please ensure that the latest metamodel is publish to the public model repo: https://models.accordproject.org/concerto/[email protected]

from concerto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.