Advertisement
klimentmichal

Validace

May 19th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1.  ValidationRules = new Dictionary<string, string>()
  2.            {
  3.               { "FirstName", @".{3,50}"},
  4.               { "SecondName", @".{3,50}"},
  5.               { "Email", @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"},
  6.                  { "Date", @"([0-3][0-9])\. (0[0-9]|1[0-2])\. ([0-9][0-9][0-9][0-9])"},
  7.                  { "City", @".{2,100}"},
  8.                  { "Passwd", @"^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$"}
  9.             };      
  10.  
  11.  
  12. /// <summary>
  13.         ///    validacni funkce
  14.         /// </summary>
  15.         /// <param name="value"></param>
  16.         /// <param name="validationRule"></param>
  17.         /// <returns>return true - if is valid</returns>
  18.         public static bool Validate(string value, string validationRule)
  19.         {
  20.             Regex rgx = new Regex(validationRule);
  21.             return rgx.IsMatch(value);
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement