コード例 #1
0
        private string BuildValidationWithLengthAttribute(StringLengthAttribute lengthAttribute, string propertyName)
        {
            var result = new StringBuilder();

            result.AppendFormat(
                @"model['{0}'].extend({{ maxLength: {{ params: {1},
                                                           message: '{2}' }} }});", propertyName, lengthAttribute.MaximumLength, lengthAttribute.LocalizableError());

            result.AppendFormat(
                @"model['{0}'].extend({{ minLength: {{ params: {1},
                                                           message: '{2}' }} }});", propertyName, lengthAttribute.MinimumLength, lengthAttribute.LocalizableError());

            return(result.ToString());
        }