I want to define a document as
numbers : ["99995", "44444", "666664".....]
The numbers shouldn't start with 0 and length should be 5. Also there should be minimum 1 element
The mongoose schema that I defined in something of this type
numbers: {
type: [String],
length : 5,
validator : (num) => {
return /[1-9]{1}\d{4}.test(num);
},
message: props => `${props.value} is not a valid number!`
}
}
But how should I put a check on the numbers length ie minimum one is required ?