meteor collections simpleschema, allowedvalues for array?

80 Views Asked by At

When i have created a schema:

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

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

1

There are 1 best solutions below

0
Ticdoc On BEST ANSWER

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.