private static string ValidatorsCodeSnippet(MaxLengthInfo info) { string result = string.Format( @"{{Validator :Validators.maxLength({1}), ErrorCode: 'maxlength', ErrorMessage: ""{0} has maximum length of {1} characters"" }}, ", info.Property.Name, info.Length); return(result); }
public void GenerateCode(IConceptInfo conceptInfo, ICodeBuilder codeBuilder) { if (conceptInfo is MaxLengthInfo) { MaxLengthInfo info = (MaxLengthInfo)conceptInfo; if (DataStructureCodeGenerator.IsTypeSupported(info.Property.DataStructure)) { codeBuilder.InsertCode(ImplementationCodeSnippet(info), MvcPropertyHelper.AttributeTag, info.Property); } } }
private static string ImplementationCodeSnippet(MaxLengthInfo info) { return(string.Format(@"[MaxLength({0})] ", info.Length)); }