-1

When i have created a schema:

  permissions: {
    type:[String],
    allowedValues: [
      'admin', 'normal',
    ],
  },

do the allowedValues checks apply for the elements inside the array?

Gobliins
  • 3,848
  • 16
  • 67
  • 122

1 Answers1

1

According to this feature request you would use this:

permissions: {
    type:[String]
},
permissions.$: {
    type: String,
    allowedValues: [
        'admin', 'normal'
    ],
}

You will need to have a way to ensure that duplicate values don't get pushed onto the array.

Ticdoc
  • 248
  • 3
  • 15