In my model I have
level: {
type: DataTypes.ENUM('state', 'service-area'),
allowNull: false,
validate: {
isIn: {
args: [
['state', 'service-area']
],
msg: 'level should be one of state,service-area'
}
}
},
assignedStates: {
type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true
},
assignedServiceAreas: {
type: DataTypes.ARRAY(DataTypes.STRING),
allowNull: true
},
I am trying to add a validator if level
is state
, and then assignedStates
should not be null. How should I do it?
source
share