Mongoose SchemaString#match receiving TypeError Mongoose SchemaString#match receiving TypeError mongoose mongoose

Mongoose SchemaString#match receiving TypeError


The regexp needs to be an actual regexp object and not a string.

Try this:

var dateTimeMatch = [  /-?[0-9]{4}(-(0[1-9]|1[0-2])(-(0[0-9]|[1-2][0-9]|3[0-1])))(T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\.[0-9]+)?(Z|(\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00)))/,  'Deceased DateTime must be in the format: 1992-12-31T23:59:59+14:00'];