public override bool IsValid(object?value) { if (value == null) { return(CanBeNull); } return(value is string text && ValidationMethods.IsMobilePhone(text)); }
public static string NullOrNotMobile([ValidatedNotNull] string?mobile, string paramName) { if (!ValidationMethods.IsMobilePhone(mobile)) { throw new ArgumentException(HB.Framework.Common.Properties.Resources.NotMobileErrorMessage, paramName); } return(mobile); }
public static string?NotMobile(string?mobile, string paramName, bool canBeNull) { if (mobile == null) { if (canBeNull) { return(null); } else { throw new ArgumentNullException(paramName); } } if (!ValidationMethods.IsMobilePhone(mobile)) { throw new ArgumentException($"Parameter:{ paramName}"); } return(mobile); }
protected override ValueTask <bool> ValidateAsync(object?value, CancellationToken token) { return(new ValueTask <bool>(ValidationMethods.IsMobilePhone(value?.ToString()))); }