Forum Discussion

HenrikHL's avatar
HenrikHL
Frequent Contributor
3 years ago
Solved

Restrict string lengths in arrays

Hi,

I was wondering if it is possible to restrict length of strings in arrays? I have the following structure:

shippingMarks:
  type: array
  minItems: 1
  description: 'List of `ShippingMarks`...'
  example: ['Made in China']
  items:
    type: string

This would allow the following:

shippingMarks: ['Made in China']

 

I would like to limit the maxLength of the strings inserted into the array - how is this done?

2 Replies

  • chichepo's avatar
    chichepo
    Frequent Contributor

    HenrikHL 
    Do you mean that kind of definition?

    chichepo_0-1691312909637.png

     

    • HenrikHL's avatar
      HenrikHL
      Frequent Contributor

      Yes - sorry for the confusion - I got mixed up.

      Thanks chichepo