Example #1
0
 public RuleViolationCollection BetweenLength(int MinLength, int MaxLength)
 {
     if (!NetTalkIsValid.HasMinMaxLength(CurrentValue, MinLength, MaxLength, true))
     {
         Add(string.Format("{0} باید بین {1} تا {2} کاراکتر باشد.", CurrentName, MinLength, MaxLength), CurrentCheck);
     }
     return(this);
 }
Example #2
0
 public RuleViolationCollection Email()
 {
     if (!NetTalkIsValid.IsEmail(CurrentValue))
     {
         Add("فرمت ایمیل وارد شده صحیح نیست", CurrentCheck);
     }
     return(this);
 }
Example #3
0
 public RuleViolationCollection NotNull()
 {
     if (NetTalkIsValid.IsNull(CurrentValue))
     {
         Add(string.Format("{0} نمی تواند خالی باشد", CurrentName), CurrentCheck);
     }
     return(this);
 }
Example #4
0
 public RuleViolationCollection MatchRegex(string Pattern)
 {
     if (!NetTalkIsValid.Match(CurrentValue, Pattern))
     {
         Add(string.Format("{0} دارای فرمت صحیح نیست", CurrentName), CurrentCheck);
     }
     return(this);
 }
Example #5
0
 public RuleViolationCollection MaxLength(int Length)
 {
     if (!NetTalkIsValid.HasLength(CurrentValue, Length, true))
     {
         Add(string.Format("طول {0} نمی تواند بیش از {1} کاراکتر باشد", CurrentName, Length), CurrentCheck);
     }
     return(this);
 }
Example #6
0
 public RuleViolationCollection MinLength(int Length)
 {
     if (!NetTalkIsValid.HasMinLength(CurrentValue, Length, true))
     {
         Add(string.Format("حداقل طول {0} باید {1} کاراکتر باشد.", CurrentName, Length), CurrentCheck);
     }
     return(this);
 }
Example #7
0
 public RuleViolationCollection FarsiChar()
 {
     if (!NetTalkIsValid.IsFarsiChar(CurrentValue))
     {
         Add(CurrentName + " فقط حروف فارسی مجاز است", CurrentCheck);
     }
     return(this);
 }
Example #8
0
 public RuleViolationCollection Digit()
 {
     if (!NetTalkIsValid.IsDigit(CurrentValue))
     {
         Add(CurrentName + "فقط اعداد مجاز است.", CurrentCheck);
     }
     return(this);
 }
Example #9
0
 public RuleViolationCollection LatinChar()
 {
     if (!NetTalkIsValid.IsLatinChar(CurrentValue))
     {
         Add(CurrentName + " فرمت وارد شده صحیح نیست - فقط حروف لاتین مجاز است", CurrentCheck);
     }
     return(this);
 }
Example #10
0
 public RuleViolationCollection Time()
 {
     if (!NetTalkIsValid.IsTime(CurrentValue))
     {
         Add("فرمت ساعت وارد شده صحیح نیست", CurrentCheck);
     }
     return(this);
 }
Example #11
0
        public static bool TryParse(string dt, out NetTalkDate result)
        {
            bool HasResult = false;

            result = null;
            try
            {
                if (NetTalkIsValid.IsDate(dt))
                {
                    Regex rg = new Regex(NetTalkPatterns.Date);
                    int   y, m, d;
                    Match r = rg.Match(dt);
                    y         = Convert.ToInt32(r.Groups[1].Value);
                    m         = Convert.ToInt32(r.Groups[2].Value);
                    d         = Convert.ToInt32(r.Groups[3].Value);
                    result    = new NetTalkDate(y, m, d);
                    HasResult = true;
                }
                else if (NetTalkIsValid.IsDatetime(dt))
                {
                    Regex rg = new Regex(NetTalkPatterns.DateTime);
                    int   y, m, d, h, min, s;

                    Match r = rg.Match(dt);
                    y         = Convert.ToInt32(r.Groups[1].Value);
                    m         = Convert.ToInt32(r.Groups[2].Value);
                    d         = Convert.ToInt32(r.Groups[3].Value);
                    h         = Convert.ToInt32(r.Groups[4].Value);
                    min       = Convert.ToInt32(r.Groups[5].Value);
                    s         = Convert.ToInt32(r.Groups[6].Value);
                    result    = new NetTalkDate(y, m, d, h, min, s, 0);
                    HasResult = true;
                }
                else if (NetTalkIsValid.IsDateTimeFactor(dt))
                {
                    Regex rg = new Regex(NetTalkPatterns.DateTimeFactor);
                    int   y, m, d, h, min, s;

                    Match r = rg.Match(dt);
                    y         = Convert.ToInt32(r.Groups[1].Value);
                    m         = Convert.ToInt32(r.Groups[2].Value);
                    d         = Convert.ToInt32(r.Groups[3].Value);
                    h         = Convert.ToInt32(r.Groups[4].Value);
                    min       = Convert.ToInt32(r.Groups[5].Value);
                    s         = 0;
                    result    = new NetTalkDate(y, m, d, h, min, s, 0);
                    HasResult = true;
                }
            }
            catch { }

            return(HasResult);
        }