Skip to content

Commit

Permalink
EDF: [premieroctet#113] allergy field is required if is_allergic is t…
Browse files Browse the repository at this point in the history
…rue in user schema
  • Loading branch information
Bastien-Wappizy committed Dec 16, 2024
1 parent a80f084 commit 7ed42d9
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { isEmailOk, isPhoneOk } = require('../../../../utils/sms')
const {schemaOptions} = require('../../../utils/schemas')
const bcrypt = require('bcryptjs')
const { DUMMY_REF, idEqual } = require('../../../utils/database')
const { ROLES , JOBS, DISCRIMINATOR_KEY, LEVEL_THRESHOLD_EXPLORER, USER_LEVEL_CURIOUS, LEVEL_THRESHOLD_AMBASSADOR, USER_LEVEL_AMBASSADOR, USER_LEVEL_EXPLORER, COMPLETED_YES, OPTIONAL_COMPLETION_FIELDS, REQUIRED_COMPLETION_FIELDS, ROLE_MEMBER, BOOLEAN_ENUM_NO, BOOLEAN_ENUM } = require('../consts')
const { ROLES , JOBS, DISCRIMINATOR_KEY, LEVEL_THRESHOLD_EXPLORER, USER_LEVEL_CURIOUS, LEVEL_THRESHOLD_AMBASSADOR, USER_LEVEL_AMBASSADOR, USER_LEVEL_EXPLORER, COMPLETED_YES, OPTIONAL_COMPLETION_FIELDS, REQUIRED_COMPLETION_FIELDS, ROLE_MEMBER, BOOLEAN_ENUM_NO, BOOLEAN_ENUM, BOOLEAN_ENUM_YES } = require('../consts')
const AddressSchema = require('../../../models/AddressSchema')
const { CREATED_AT_ATTRIBUTE } = require('../../../../utils/consts')

Expand Down Expand Up @@ -196,7 +196,7 @@ const UserSchema = new Schema({
},
allergy: {
type: String,
required: false
required: [function () {this.is_allergic == BOOLEAN_ENUM_YES},`Les allergies doivent être renseignées pour les personnes allergiques`],
},
}, {...schemaOptions, ...DISCRIMINATOR_KEY})

Expand Down

0 comments on commit 7ed42d9

Please sign in to comment.