示例#1
0
        public override bool IsValid(object?value)
        {
            if (value == null)
            {
                return(CanBeNull);
            }

            return(value is string text && ValidationMethods.IsMobilePhone(text));
        }
示例#2
0
        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);
        }
示例#3
0
        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())));
 }