Skip to content

Latest commit

 

History

History
27 lines (25 loc) · 596 Bytes

array-validations.md

File metadata and controls

27 lines (25 loc) · 596 Bytes

Array validations

  • required: can't be undefined (default: false)
  • sparse: can have undefined items (default: true)
  • unique: can't have duplicate items (default: false)
  • minLength: minimum quantity of items
  • maxLength: maximum quantity of items
  • exactLength: exact quantity of items
const Group = attributes({
  members: {
    type: Array,
    itemType: String,
    minLength: 2,
    maxLength: 5,
    sparse: false,
    unique: true
  },
  leaders: {
    type: Array,
    itemType: String,
    minLength: 1,
    maxLength: { attr: 'members' }
  }
})