Skip to content

Commit 7f6e7ee

Browse files
committed
added data annotations on model properties.
1 parent b840287 commit 7f6e7ee

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/main/resources/handlebars/aspnetcore/model.mustache

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@ namespace {{packageName}}.Models
2828
{{/description}}
2929
{{#required}}
3030
[Required]
31-
{{/required}}
31+
{{/required}}{{#pattern}}
32+
[RegularExpression("{{{pattern}}}")]{{/pattern}}{{#minLength}}{{#maxLength}}
33+
[StringLength({{maxLength}}, MinimumLength={{minLength}})]{{/maxLength}}{{/minLength}}{{#minLength}}{{^maxLength}}
34+
[MinLength({{minLength}})]{{/maxLength}}{{/minLength}}{{^minLength}}{{#maxLength}}
35+
[MaxLength({{maxLength}})]{{/maxLength}}{{/minLength}}{{#minimum}}{{#maximum}}
36+
[Range({{minimum}}, {{maximum}})]{{/maximum}}{{/minimum}}
3237
[DataMember(Name="{{baseName}}")]
3338
{{#isEnum}}
3439
public {{{datatypeWithEnum}}}{{#isEnum}}{{^isContainer}}?{{/isContainer}}{{/isEnum}} {{name}} { get; set; }

0 commit comments

Comments
 (0)