I need to add validation for mobile number and email field, if user will do enable sms_alert/mail_alert, then mobile_numbers/emails must be a "required field" and if no then user may or may not enter mobile_numbers/emails my pydantic model is
class Info(BaseModel):
enable_mail_alert :str = 'n'
enable_sms_alert: str = 'n'
emails: str ``
mobile_numbers: str
@validator('mobile_numbers')
def clean_space(cls,mobile_numbers,enable_sms_alert):
if 'enable_sms_alert' == 'y':
if mobile_numbers=='' or mobile_numbers==None or mobile_numbers=='None':
raise ValueError('mobile_numbers field is required')
Above code giving me error as pydantic.errors.ConfigError: Invalid signature for validator <function info_update.clean_space at 0x7f9316664940>: (cls, mobile_numbers, enable_sms_alert), should be: (cls, value, values, config, field), "values", "config" and "field" are all optional.