/// <summary> /// /// </summary> public FormatValidation.Builder FormatValidation(FormatValidation component) { #if MVC component.ViewContext = this.HtmlHelper != null ? this.HtmlHelper.ViewContext : null; #endif return(new FormatValidation.Builder(component)); }
/// <summary> /// /// </summary> public FormatValidation.Builder FormatValidation(FormatValidation component) { return(new FormatValidation.Builder(component)); }
protected override void OnMetadataProcess(ModelMetadata meta, string name, ViewDataDictionary viewData, ControllerContext context) { base.OnMetadataProcess(meta, name, viewData, context); if (meta.IsRequired) { this.AllowBlank = false; } if (this.EmptyText.IsEmpty() && meta.Watermark.IsNotEmpty()) { this.EmptyText = meta.Watermark; } string type = meta.DataTypeName; if (type.IsNotEmpty()) { switch (type) { case "Date": this.InputType = Ext.Net.InputType.Date; break; case "DateTime": this.InputType = Ext.Net.InputType.DateTime; break; case "EmailAddress": this.InputType = Ext.Net.InputType.Email; this.StandardVtype = ValidationType.Email; break; case "Password": this.InputType = Ext.Net.InputType.Password; break; case "Time": this.InputType = Ext.Net.InputType.Time; break; case "Url": this.InputType = Ext.Net.InputType.Url; this.StandardVtype = ValidationType.Url; break; } } if (meta.AdditionalValues.ContainsKey(AbstractValidationAttribute.KEY)) { ValidationCollection validations = (ValidationCollection)meta.AdditionalValues[AbstractValidationAttribute.KEY]; AbstractValidation required = validations.FirstOrDefault(v => v is PresenceValidation); if (required != null) { this.AllowBlank = false; if (required.Message.IsNotEmpty()) { this.BlankText = required.Message; } } AbstractValidation email = validations.FirstOrDefault(v => v is EmailValidation); if (email != null) { this.StandardVtype = ValidationType.Email; if (email.Message.IsNotEmpty()) { this.VtypeText = email.Message; } } LengthValidation length = validations.FirstOrDefault(v => v is LengthValidation) as LengthValidation; if (length != null) { if (length.Max != int.MaxValue) { this.MaxLength = length.Max; } if (length.Min != int.MinValue) { this.MinLength = length.Min; } if (length.Message.IsNotEmpty()) { this.MaxLengthText = length.Message; this.MinLengthText = length.Message; } } FormatValidation format = validations.FirstOrDefault(v => v is FormatValidation) as FormatValidation; if (format != null) { this.Regex = format.Matcher; if (format.Message.IsNotEmpty()) { this.RegexText = format.Message; } } } }