Ejemplo n.º 1
0
        private static string BuildValidationWithEmailLengthAttribute(EmailAddressAttribute emailValidationAttribute, string propertyName)
        {
            Type      type  = typeof(EmailAddressAttribute);
            FieldInfo info  = type.GetField("_regex", BindingFlags.NonPublic | BindingFlags.Static);
            var       value = info.GetValue(null);

            return
                (string.Format(
                     @"model['{0}'].extend({{
                         pattern: {{
                                    message: '{2}',
                                    params: /{1}/
                                    }} }});", propertyName, value, emailValidationAttribute.LocalizableError()));
        }