修改input模板,支持更多DataAnnotations属性
This commit is contained in:
parent
2eecda29a4
commit
d7f0fac13c
@ -86,10 +86,16 @@ if (@column.WhetherAddUpdate == "Y"){
|
|||||||
@if(@column.WhetherRequired=="Y"){
|
@if(@column.WhetherRequired=="Y"){
|
||||||
@:[Required(ErrorMessage = "@(@column.ColumnComment)不能为空")]
|
@:[Required(ErrorMessage = "@(@column.ColumnComment)不能为空")]
|
||||||
}
|
}
|
||||||
|
@if(@column.NetType.StartsWith("string")&&!@column.RuleItems.Any(t=>t.Type=="length")){
|
||||||
|
@:[StringLength(@(@column.ColumnLength), ErrorMessage = "@(@column.ColumnComment)不能超过@(@column.ColumnLength)个字符")]
|
||||||
|
}
|
||||||
@if(@column.AnyRule){
|
@if(@column.AnyRule){
|
||||||
@foreach(var rule in @column.RuleItems){
|
@foreach(var rule in @column.RuleItems){
|
||||||
@if(rule.Type=="pattern"){
|
@if(rule.Type=="pattern"){
|
||||||
@:[RegularExpression(@@"@(@rule.Pattern)", ErrorMessage = "@(@rule.Message)")]
|
@:[RegularExpression(@@"@(@FormatPattern(rule.Pattern))", ErrorMessage = "@(@rule.Message)")]
|
||||||
|
}
|
||||||
|
@if(rule.Type=="length"){
|
||||||
|
@:[StringLength(@(@rule.Max),MinimumLength = @(@rule.Min), ErrorMessage = "@(@column.ColumnComment)只能是@(@rule.Min)至@(@rule.Max)字符")]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,10 +143,16 @@ if (@column.WhetherAddUpdate == "Y"){
|
|||||||
@if(@column.WhetherRequired=="Y"){
|
@if(@column.WhetherRequired=="Y"){
|
||||||
@:[Required(ErrorMessage = "@(@column.ColumnComment)不能为空")]
|
@:[Required(ErrorMessage = "@(@column.ColumnComment)不能为空")]
|
||||||
}
|
}
|
||||||
|
@if(@column.NetType.StartsWith("string")&&!@column.RuleItems.Any(t=>t.Type=="length")){
|
||||||
|
@:[StringLength(@(@column.ColumnLength), ErrorMessage = "@(@column.ColumnComment)不能超过@(@column.ColumnLength)个字符")]
|
||||||
|
}
|
||||||
@if(@column.AnyRule){
|
@if(@column.AnyRule){
|
||||||
@foreach(var rule in @column.RuleItems){
|
@foreach(var rule in @column.RuleItems){
|
||||||
@if(rule.Type=="pattern"){
|
@if(rule.Type=="pattern"){
|
||||||
@:[RegularExpression(@@"@(@rule.Pattern)", ErrorMessage = "@(@rule.Message)")]
|
@:[RegularExpression(@@"@(@FormatPattern(rule.Pattern))", ErrorMessage = "@(@rule.Message)")]
|
||||||
|
}
|
||||||
|
@if(rule.Type=="length"){
|
||||||
|
@:[StringLength(@(@rule.Max),MinimumLength = @(@rule.Min), ErrorMessage = "@(@column.ColumnComment)只能是@(@rule.Min)至@(@rule.Max)字符")]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -175,4 +187,15 @@ if (@column.WhetherAddUpdate == "Y"){
|
|||||||
@:/// </summary>
|
@:/// </summary>
|
||||||
@:public string OldFieldName { get; set; }
|
@:public string OldFieldName { get; set; }
|
||||||
@:}
|
@:}
|
||||||
|
}
|
||||||
|
@{
|
||||||
|
string FormatPattern(string pattern)
|
||||||
|
{
|
||||||
|
if (pattern.EndsWith('g'))
|
||||||
|
{
|
||||||
|
pattern = pattern.TrimEnd('g');
|
||||||
|
}
|
||||||
|
pattern = pattern.Trim('/');
|
||||||
|
return pattern;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user