Ejemplo n.º 1
0
 /// <summary>Creates a new RuleArgs object for RegEx.</summary>
 /// <param name="pPropertyName">Name of the property to validate.</param>
 /// <param name="pPattern">Built-in regex pattern to use.</param>
 public RegExRuleArgs(string pPropertyName, RegExPatterns pPattern)
     :
     base(pPropertyName)
 {
     _regEx           = new Regex(GetPattern(pPattern));
     _messageTemplate = GetPatternMessageTemplate(pPattern);
 }
Ejemplo n.º 2
0
            /// <summary>
            /// Returns the specified built-in regex pattern.
            /// </summary>
            /// <param name="pattern">Pattern to return.</param>
            public static string GetPattern(RegExPatterns pattern)
            {
                switch (pattern)
                {
                case RegExPatterns.SSN:
                    return(@"^\d{3}-\d{2}-\d{4}$");

                case RegExPatterns.Email:
                    return(@"^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$");

                default:
                    return(string.Empty);
                }
            }
Ejemplo n.º 3
0
            /// <summary>Returns the specified built-in message template for this pattern.</summary>
            /// <remarks>Added by IdeaBlade; not in the Csla original.
            /// <para>ToDo: Localize message templates.</para>
            /// </remarks>
            public static string GetPatternMessageTemplate(RegExPatterns pPattern)
            {
                switch (pPattern)
                {
                case RegExPatterns.SSN:
                    return("{0} is not a valid Social Security Number");

                case RegExPatterns.Email:
                    return("{0} is not a valid email address");

                case RegExPatterns.USPhone: // Added by IdeaBlade; not in CSLA.
                    return("{0} is not a valid U.S. phone number, e.g. (212) 555-1212");

                default:
                    return(string.Empty);
                }
            }
Ejemplo n.º 4
0
            /// <summary>Returns the specified built-in regex pattern.</summary>
            public static string GetPattern(RegExPatterns pPattern)
            {
                switch (pPattern)
                {
                case RegExPatterns.SSN:
                    return(@"^\d{3}-\d{2}-\d{4}$");

                case RegExPatterns.Email:
                    return(@"\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b");

                case RegExPatterns.USPhone: // Added by IdeaBlade; not in CSLA.
                    return(@"^((\([2-9]\d{2}\) ?)|([2-9]\d{2}[-.]))\d{3}[-.]\d{4}$");

                default:
                    return(string.Empty);
                }
            }
Ejemplo n.º 5
0
        public static string GetPattern(RegExPatterns pattern)
        {
            switch (pattern)
            {
            case RegExPatterns.Ssn:
                return(@"^\d{3}-\d{2}-\d{4}$");

            case RegExPatterns.Email:
                return(@"^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$");

            case RegExPatterns.Integer:
                return(@"^[0-9]*$");

            case RegExPatterns.StateCode:
                return(@"^(A[LKZR]|C[AOT]|DE|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$");

            default:
                return(string.Empty);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new object.
 /// </summary>
 /// <param name="propertyName">Name of the property to validate.</param>
 /// <param name="pattern">Built-in regex pattern to use.</param>
 public RegExMatchRuleArgs(string propertyName, RegExPatterns pattern)
     :
     base(propertyName)
 {
     _regEx = new Regex(GetPattern(pattern));
 }
Ejemplo n.º 7
0
 public static RuleMethod AddRegExMatchRule(RuleList pRuleList,
                                            BusinessProperty pColumn, RegExPatterns pRegExMatchPattern)
 {
     return(pRuleList.Add(RegExMatch, new RegExRuleArgs(pColumn.Name, pRegExMatchPattern)));
 }
Ejemplo n.º 8
0
 public static RuleMethod AddRegExMatchRule(RuleList pRuleList,
                                            string pPropertyName, RegExPatterns pRegExMatchPattern)
 {
     return(pRuleList.Add(RegExMatch, new RegExRuleArgs(pPropertyName, pRegExMatchPattern)));
 }
Ejemplo n.º 9
0
 public static RegexConstraint GetConstraint(RegExPatterns pattern, string resourceKey)
 {
     return(new RegexConstraint(resourceKey, GetPattern(pattern)));
 }
Ejemplo n.º 10
0
 public static RegexConstraint GetConstraint(RegExPatterns pattern)
 {
     return(new RegexConstraint(GetPattern(pattern)));
 }