I want to create a form builder and I have dynamics fields and validation. for example, sometimes I have fields like this
@IsNotEmpty()
name: string
@IsNotEmpty()
@IsEmail()
email: string
@IsNotEmpty()
@Length(11)
mobile: string
and sometimes I have fields like this:
@IsNotEmpty()
name: string
@IsNumber()
age: number
How can I handle it?
I didn't understand your question but I think you need to add
IsOptional()on stuff that you won't check unless they have value, on the other hand you can useValidateIf()on fields depends on others,