public static Validator Create(JsonValidationRule rule) { int minLength = (int)(rule.ValidationParameters["min"] ?? 0); int maxLength = (int)(rule.ValidationParameters["max"] ?? Number.MAX_VALUE); return(new StringLengthValidator(minLength, maxLength).Validate); }
public static Validator Create(JsonValidationRule rule) { Number min = (Number)rule.ValidationParameters["min"]; Number max = (Number)rule.ValidationParameters["max"]; return(new RangeValidator(min, max).Validate); }
public static Validator Create(JsonValidationRule rule) { int minLength = (int)rule.ValidationParameters["minimumLength"]; int maxLength = (int)rule.ValidationParameters["maximumLength"]; return(new StringLengthValidator(minLength, maxLength).Validate); }
internal static FormContext ParseJsonOptions(JsonValidationOptions options) { // First hook up the form logic FormElement formElement = (FormElement)Document.GetElementById(options.FormId); DOMElement validationSummaryElement = (!ValidationUtil.StringIsNullOrEmpty(options.ValidationSummaryId)) ? Document.GetElementById(options.ValidationSummaryId) : null; FormContext formContext = new FormContext(formElement, validationSummaryElement); formContext.EnableDynamicValidation(); formContext.ReplaceValidationSummary = options.ReplaceValidationSummary; // Then hook up the field logic for (int i = 0; i < options.Fields.Length; i++) { JsonValidationField field = options.Fields[i]; DOMElement[] fieldElements = GetFormElementsWithName(formElement, field.FieldName); DOMElement validationMessageElement = (!ValidationUtil.StringIsNullOrEmpty(field.ValidationMessageId)) ? Document.GetElementById(field.ValidationMessageId) : null; FieldContext fieldContext = new FieldContext(formContext); ArrayList.AddRange((ArrayList)(object)fieldContext.Elements, fieldElements); fieldContext.ValidationMessageElement = validationMessageElement; fieldContext.ReplaceValidationMessageContents = field.ReplaceValidationMessageContents; // Hook up rules for (int j = 0; j < field.ValidationRules.Length; j++) { JsonValidationRule rule = field.ValidationRules[j]; Validator validator = ValidatorRegistry.GetValidator(rule); if (validator != null) { Validation validation = new Validation(); validation.FieldErrorMessage = rule.ErrorMessage; validation.Validator = validator; ArrayList.Add((ArrayList)(object)fieldContext.Validations, validation); } } fieldContext.EnableDynamicValidation(); ArrayList.Add((ArrayList)(object)formContext.Fields, fieldContext); } // hook up callback so that it can be executed by the AJAX code ArrayList registeredValidatorCallbacks = (ArrayList)Type.GetField(formElement, "validationCallbacks"); if (registeredValidatorCallbacks == null) { registeredValidatorCallbacks = new ArrayList(); Type.SetField(formElement, "validationCallbacks", registeredValidatorCallbacks); } Type.InvokeMethod(registeredValidatorCallbacks, "push", (ValidationCallback) delegate() { return(ValidationUtil.ArrayIsNullOrEmpty(formContext.Validate("submit"))); }); return(formContext); }
public static Validator Create(JsonValidationRule rule) { Number min = (Number)rule.ValidationParameters["minimum"]; Number max = (Number)rule.ValidationParameters["maximum"]; return new RangeValidator(min, max).Validate; }
public static Validator Create(JsonValidationRule rule) { return(new RequiredValidator().Validate); }
public static Validator Create(JsonValidationRule rule) { string pattern = (string)rule.ValidationParameters["pattern"]; return(new RegularExpressionValidator(pattern).Validate); }
public static Validator GetValidator(JsonValidationRule rule) { ValidatorCreator creator = (ValidatorCreator)Validators[rule.ValidationType]; return((creator != null) ? creator(rule) : null); }
public static Validator Create(JsonValidationRule rule) { return new NumberValidator().Validate; }
public static Validator GetValidator(JsonValidationRule rule) { ValidatorCreator creator = (ValidatorCreator)Validators[rule.ValidationType]; return (creator != null) ? creator(rule) : null; }
public static Validator Create(JsonValidationRule rule) { int minLength = (int)rule.ValidationParameters["minimumLength"]; int maxLength = (int)rule.ValidationParameters["maximumLength"]; return new StringLengthValidator(minLength, maxLength).Validate; }
public static Validator Create(JsonValidationRule rule) { int minLength = (int)(rule.ValidationParameters["min"] ?? 0); int maxLength = (int)(rule.ValidationParameters["max"] ?? Number.MAX_VALUE); return new StringLengthValidator(minLength, maxLength).Validate; }
public static Validator Create(JsonValidationRule rule) { return new RequiredValidator().Validate; }
public static Validator Create(JsonValidationRule rule) { string pattern = (string)rule.ValidationParameters["pattern"]; return new RegularExpressionValidator(pattern).Validate; }
public static Validator Create(JsonValidationRule rule) { return(new NumberValidator().Validate); }