Skip to content

Commit 87e8e1e

Browse files
committed
Complete sanitization-group
Add advanced-group to version-1.0.0
1 parent f760341 commit 87e8e1e

35 files changed

Lines changed: 1789 additions & 1 deletion

src/app/shared/data/versions.data.ts

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,223 @@ export const Versions: IVersion[] = [
944944
]
945945
},
946946
]
947+
},
948+
{
949+
title: "Sanitization",
950+
posts: [
951+
{
952+
id: "sanitization-introduction",
953+
title: "Sanitization Introduction",
954+
route: resolveRoute(VERSIONS["1.0.0"], "sanitization-introduction"),
955+
sections: [
956+
{
957+
id: "examples",
958+
title: "Examples"
959+
},
960+
{
961+
id: "example1",
962+
title: "Example 1"
963+
},
964+
{
965+
id: "example2",
966+
title: "Example 2"
967+
}
968+
]
969+
},
970+
{
971+
id: "custom-sanitizer-func",
972+
title: ".CustomSanitizer()",
973+
isCode: true,
974+
route: resolveRoute(VERSIONS["1.0.0"], "custom-sanitizer-func"),
975+
sections: [
976+
{
977+
id: "definitions",
978+
title: "Definitions"
979+
},
980+
{
981+
id: "examples",
982+
title: "Examples"
983+
},
984+
{
985+
id: "example1",
986+
title: "Example 1"
987+
},
988+
{
989+
id: "example2",
990+
title: "Example 2"
991+
}
992+
]
993+
},
994+
{
995+
id: "to-lower-func",
996+
title: ".ToLower()",
997+
isCode: true,
998+
route: resolveRoute(VERSIONS["1.0.0"], "to-lower-func"),
999+
sections: [
1000+
{
1001+
id: "definition",
1002+
title: "Definition"
1003+
},
1004+
{
1005+
id: "examples",
1006+
title: "Examples"
1007+
},
1008+
{
1009+
id: "example1",
1010+
title: "Example 1"
1011+
}
1012+
]
1013+
},
1014+
{
1015+
id: "to-upper-func",
1016+
title: ".ToUpper()",
1017+
isCode: true,
1018+
route: resolveRoute(VERSIONS["1.0.0"], "to-upper-func"),
1019+
sections: [
1020+
{
1021+
id: "definition",
1022+
title: "Definition"
1023+
},
1024+
{
1025+
id: "examples",
1026+
title: "Examples"
1027+
},
1028+
{
1029+
id: "example1",
1030+
title: "Example 1"
1031+
}
1032+
]
1033+
},
1034+
{
1035+
id: "to-utc-func",
1036+
title: ".ToUtc()",
1037+
isCode: true,
1038+
route: resolveRoute(VERSIONS["1.0.0"], "to-utc-func"),
1039+
sections: [
1040+
{
1041+
id: "definition",
1042+
title: "Definition"
1043+
},
1044+
{
1045+
id: "examples",
1046+
title: "Examples"
1047+
},
1048+
{
1049+
id: "example1",
1050+
title: "Example 1"
1051+
}
1052+
]
1053+
},
1054+
{
1055+
id: "trim-end-func",
1056+
title: ".TrimEnd()",
1057+
isCode: true,
1058+
route: resolveRoute(VERSIONS["1.0.0"], "trim-end-func"),
1059+
sections: [
1060+
{
1061+
id: "definition",
1062+
title: "Definition"
1063+
},
1064+
{
1065+
id: "examples",
1066+
title: "Examples"
1067+
},
1068+
{
1069+
id: "example1",
1070+
title: "Example 1"
1071+
}
1072+
]
1073+
},
1074+
{
1075+
id: "trim-func",
1076+
title: ".Trim()",
1077+
isCode: true,
1078+
route: resolveRoute(VERSIONS["1.0.0"], "trim-func"),
1079+
sections: [
1080+
{
1081+
id: "definitions",
1082+
title: "Definitions"
1083+
},
1084+
{
1085+
id: "examples",
1086+
title: "Examples"
1087+
},
1088+
{
1089+
id: "example1",
1090+
title: "Example 1"
1091+
},
1092+
{
1093+
id: "example2",
1094+
title: "Example 2"
1095+
}
1096+
]
1097+
},
1098+
{
1099+
id: "trim-start-func",
1100+
title: ".TrimStart()",
1101+
isCode: true,
1102+
route: resolveRoute(VERSIONS["1.0.0"], "trim-start-func"),
1103+
sections: [
1104+
{
1105+
id: "definition",
1106+
title: "Definition"
1107+
},
1108+
{
1109+
id: "examples",
1110+
title: "Examples"
1111+
},
1112+
{
1113+
id: "example1",
1114+
title: "Example 1"
1115+
}
1116+
]
1117+
},
1118+
]
1119+
},
1120+
{
1121+
title: "Advanced",
1122+
posts: [
1123+
{
1124+
id: "full-model-validation",
1125+
title: "Full Model Validation",
1126+
route: resolveRoute(VERSIONS["1.0.0"], "full-model-validation"),
1127+
sections: [
1128+
{
1129+
id: "examples",
1130+
title: "Examples"
1131+
},
1132+
{
1133+
id: "example1",
1134+
title: "Example 1"
1135+
},
1136+
{
1137+
id: "example2",
1138+
title: "Example 2"
1139+
}
1140+
]
1141+
},
1142+
{
1143+
id: "validate-vs-result",
1144+
title: "Validate() vs Result()",
1145+
route: resolveRoute(VERSIONS["1.0.0"], "validate-vs-result"),
1146+
sections: [
1147+
{
1148+
id: "how-to-use",
1149+
title: "How to Use?"
1150+
},
1151+
{
1152+
id: "validate",
1153+
title: ".Validate()",
1154+
isCode: true
1155+
},
1156+
{
1157+
id: "result",
1158+
title: ".Result()",
1159+
isCode: true
1160+
}
1161+
]
1162+
},
1163+
]
9471164
}
9481165
]
9491166
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<app-post *ngIf="post" [post]="post" [previous]="previous" [next]="next">
2+
3+
<!-- Article -->
4+
<ng-container class="article">
5+
<p>
6+
The <code>ValidationResult</code> class enables us to validate all of data-model properties together,
7+
instead of validating each one individually.
8+
</p>
9+
<div>
10+
<h2 class="section-heading">
11+
Examples
12+
<a id="examples" aria-hidden="true" class="section-heading-ref"></a>
13+
</h2>
14+
<ul>
15+
<li>
16+
<h3>
17+
Example 1 :
18+
<a id="example1" aria-hidden="true" class="section-heading-ref"></a>
19+
</h3>
20+
<strong>To do : </strong>
21+
<i>
22+
<ol>
23+
<li>
24+
Validate that the person's name length is not more than 5 characters.
25+
</li>
26+
<li>
27+
Validate that the person's age must be at least 20 years.
28+
</li>
29+
</ol>
30+
</i>
31+
<p>
32+
Let's start with creating a new class called <code>Person</code>.
33+
</p>
34+
<pre class="code-block">
35+
<code appHighlight>{{person1}}</code>
36+
</pre>
37+
<pre class="code-block">
38+
<code appHighlight>{{example1}}</code>
39+
</pre>
40+
</li>
41+
<li>
42+
<h3>
43+
Example 2 :
44+
<a id="example2" aria-hidden="true" class="section-heading-ref"></a>
45+
</h3>
46+
<strong>Or you can use the following syntax instead.</strong>
47+
<pre class="code-block">
48+
<code appHighlight>{{example2}}</code>
49+
</pre>
50+
</li>
51+
</ul>
52+
</div>
53+
</ng-container>
54+
<!-- End Article -->
55+
56+
</app-post>

src/app/version1.0.0/components/advanced/full-model-validation/full-model-validation.component.sass

Whitespace-only changes.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import {Component, OnInit} from "@angular/core";
2+
import {IPost, DocService} from "../../../../shared";
3+
4+
@Component({
5+
selector: "app-full-model-validation",
6+
templateUrl: "./full-model-validation.component.html",
7+
styleUrls: ["./full-model-validation.component.sass"]
8+
})
9+
export class FullModelValidationComponent implements OnInit {
10+
11+
versionId = "1.0.0";
12+
postId = "full-model-validation";
13+
14+
post: IPost;
15+
previous: IPost;
16+
next: IPost;
17+
18+
//#region Codes
19+
person1 = `
20+
public class Person
21+
{
22+
public string Name { get; set; }
23+
public int Age { get; set; }
24+
}`;
25+
26+
example1 = `
27+
var model = new Person
28+
{
29+
Name = "John Smith",
30+
Age = 18
31+
};
32+
33+
var nameValidator = Validator.Create(model, "Name")
34+
.MaxLength(5, "Invalid name length.");
35+
36+
var ageValidator = Validator.Create(model, "Age")
37+
.Min(20, "Not allowed age.");
38+
39+
var errors = ValidationResult.Validate(nameValidator, ageValidator);
40+
41+
/*
42+
errors value will be a List<ValidationError>
43+
44+
[
45+
{
46+
PropertyName = "Name",
47+
ErrorMessages = [
48+
"Invalid name length."
49+
]
50+
},
51+
{
52+
PropertyName = "Age",
53+
ErrorMessages = [
54+
"Not allowed age."
55+
]
56+
}
57+
]
58+
*/`;
59+
60+
example2 = `
61+
var model = new Person
62+
{
63+
Name = "John Smith",
64+
Age = 18
65+
};
66+
67+
var errors = ValidationResult.Validate(
68+
Validator.Create(model, "Name")
69+
.MaxLength(5, "Invalid name length.")
70+
,
71+
Validator.Create(model, "Age")
72+
.Min(20, "Not allowed age.")
73+
);
74+
75+
/*
76+
errors value will be a List<ValidationError>
77+
78+
[
79+
{
80+
PropertyName = "Name",
81+
ErrorMessages = [
82+
"Invalid name length."
83+
]
84+
},
85+
{
86+
PropertyName = "Age",
87+
ErrorMessages = [
88+
"Not allowed age."
89+
]
90+
}
91+
]
92+
*/`;
93+
//#endregion
94+
95+
ngOnInit(): void {
96+
this.post = DocService.findPost(this.versionId, this.postId);
97+
98+
const prevNext = DocService.GetPrevNextPosts(this.versionId, this.postId);
99+
this.previous = prevNext.previous;
100+
this.next = prevNext.next;
101+
}
102+
103+
}

0 commit comments

Comments
 (0)