SimpleSchema how can I require arrays to have at least one element? [SOLVED]

I need the arrays to have at least one element.
The following Schema does not work:

let schema = new SimpleSchema({
  levels: { 
    type: [String], 
    min: 1,
    allowedValues: ['basic', 'intermediate', 'advanced'] 
  },
  preferences: { 
    type: [String], 
    min: 1,
    allowedValues: ['TheSimpsons', 'Naruto'] 
  }
});

I solved it with minCount instead of min.

1 Like