public static IRuleBuilder UsernameOrEmail(this IRuleBuilder ruleBuilder) { return ruleBuilder .NotEmpty() .When( ???condition???, () => //in case UsernameOrEmail is an eMail – check if string is not null and string contains the char ‘@’ // ??? no clue here about the required syntax. Somthing like this: em => em != null && em.Contains(‘@’), () => ??? { .Email() //perform validation for an email address } ).Otherwise( () => //it is a username { .Username() //perform validation for a username }); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)