Skip to content

help with .or() #629

@chrismcv

Description

@chrismcv

Hi, using react validation mixin, which uses this library.

I've created my rules:

  validatorTypes: ->
    patient = Joi.object().keys
      forename: Joi.string().min(3).max(100).required().label('Forename')
      surname: Joi.string().allow(null).label('Surname')
      mobileTelephone: Joi.string().min(3).max(100).required().label('Mobile Telephone')
      homeTelephone:Joi.string().min(3).max(100).required().label('Home Telephone')
      workTelephone:Joi.string().min(3).max(100).required().label('Work Telephone')
    patient.or('mobileTelephone', 'homeTelephone', 'workTelephone')
    return Joi.object().keys 
      patient:patient

The or( isn't behaving like I would expect. I'm expecting one of mobile/home/work phone numbers to be required, however, at the moment it seems to be requiring all 3. I'm also doing some nesting, but I don't think this is the issue.

Thanks,
Chris

Metadata

Metadata

Assignees

Labels

supportQuestions, discussions, and general support

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions