I am trying to write a RAML data type fragment that would strictly define how selectedDate should be accepted
#%RAML 1.0 DataType
properties:
selectedDate?:
type: array | date-only
example: ["2020-08-05", "2020-08-06"]
example:
selectedDate: "2020-08-05"
User can send the date in string as date-only or an array, as shown in the two examples above. But I need to allow the date in a date-only format, even when its sent in an array. But here array allows strings as well that are not dates.
I feel I am not explaining it well. Any help is appreciated.
You can define the array to be an array based on a type for the elements by adding the []
suffix to the type: date-only[]
. You can also encapsulate that definition into a new type.