I'm investigating the possibilities of the new Data Structures syntax in API Blueprint, especially MSON. Is it possible to attach or rather specify something like a pattern (regex)? Don't found anything on this topic.
Use pattern in API Blueprint / MSON
Asked Answered
Would you be able to elaborate slightly on what you are trying to achieve. Are you looking to specify an attribute with a value that is a regex pattern, or use a regex pattern for validation of a value? –
Shult
I want to validate a value using a regex like + firstname: Mamfred (required, pattern[/regex/]) –
Britten
To be more precise, we use Aglio and since version 2 there is a basic support for Data Structures and Attributes. The library renders also an JSON Schema. And for that an automatic pattern description would be very useful. But if MSON does not support those... –
Britten
To provide regex validation for your data structure you will need to provide a JSON Schema which has this validation rule. For example, like the following:
### View a Questions Detail [GET]
+ Response 200 (application/json)
+ Attributes
+ question: `Favourite programming language?` (string)
+ Schema
{
"properties": {
"question": {
"type": "string",
"pattern": "^Favourite.*$"
}
}
}
I know. I'm asking because Aglio automatically adds a Schema on basis of the attribute / Data Structures... –
Britten
© 2022 - 2024 — McMap. All rights reserved.