|
1 | 1 | [[chapter_13_database_layer_validation]]
|
2 | 2 | == Validation at the Database Layer
|
3 | 3 |
|
4 |
| -// RITA: Update the warning since you have reviewed the chapter text in detail? |
5 |
| -.🚧 Warning, Chapter update in progress |
6 |
| -******************************************************************************* |
7 |
| -This chapter is currently in the process of being rewritten for the 3e. |
8 |
| -
|
9 |
| -The code listings should all be valid, |
10 |
| -and work with Python3.12 + Django 4, |
11 |
| -but I haven't reviewed the chapter text in detail yet. |
12 |
| -
|
13 |
| -******************************************************************************* |
14 | 4 |
|
15 | 5 | ((("user interactions", "validating inputs at database layer", id="UIdblayer13")))
|
16 | 6 | ((("database testing", "database-layer validation", id="DBTdblayer13")))
|
@@ -263,18 +253,20 @@ been passed an error variable, and if so, we do this:
|
263 | 253 | ((("form control classes (Bootstrap)")))
|
264 | 254 | Take a look at the https://getbootstrap.com/docs/5.3/forms/validation/#server-side[Bootstrap docs] for more
|
265 | 255 | info on form controls.
|
266 |
| -footnote:[... and ignore their advice to prefer client-side validation. |
267 |
| -Ideally, having both server- and client-side validation is the best. |
268 |
| -If you can't do both, then server-side validation is the one you really can't do |
269 |
| -without. |
270 |
| -Check the |
271 |
| -https://owasp.org/www-project-secure-coding-practices-quick-reference-guide/stable-en/02-checklist/05-checklist.html[OWASP checklist], |
272 |
| -if you are not convinced yet. |
273 |
| -Client-side validation will provide faster feedback on the UI, but |
274 |
| -https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html#client-side-vs-server-side-validation[it is not a security measure.] |
275 |
| -Server-side validation is indispensable for handling any input |
276 |
| -that gets processed by the server--and it will also provide albeit slower, |
277 |
| -feedback for the client side.] |
| 256 | + |
| 257 | +TIP: However, ignore the Bootstrap docs' advice to prefer client-side |
| 258 | + validation. |
| 259 | + Ideally, having both server- and client-side validation is the best. |
| 260 | + If you can't do both, then server-side validation is the one you really |
| 261 | + can't do without. |
| 262 | + Check the |
| 263 | + https://owasp.org/www-project-secure-coding-practices-quick-reference-guide/stable-en/02-checklist/05-checklist.html[OWASP checklist], |
| 264 | + if you are not convinced yet. |
| 265 | + Client-side validation will provide faster feedback on the UI, but |
| 266 | + https://cheatsheetseries.owasp.org/cheatsheets/Input_Validation_Cheat_Sheet.html#client-side-vs-server-side-validation[it is not a security measure.] |
| 267 | + Server-side validation is indispensable for handling any input |
| 268 | + that gets processed by the server--and it will also provide albeit slower, |
| 269 | + feedback for the client side.] |
278 | 270 |
|
279 | 271 |
|
280 | 272 | // CSANAD: these are the new docs for Bootstrap, but for some reason they begin
|
@@ -629,7 +621,7 @@ We should also remind ourselves not to forget to remove this early return:
|
629 | 621 |
|
630 | 622 | And now, we can focus on making our code a little neater.
|
631 | 623 |
|
632 |
| -TIP: When working on a new feature, it's common to realize partway through that |
| 624 | +TIP: When working on a new feature, it's common to realise partway through that |
633 | 625 | a refactor of the application is needed. Adding an early return to the FT
|
634 | 626 | you're currently working on allows you to perform this refactor against
|
635 | 627 | passing FTs, even while the feature is still in progress.
|
@@ -1089,13 +1081,14 @@ $ pass:quotes[*python src/manage.py test functional_tests*]
|
1089 | 1081 | OK
|
1090 | 1082 | ----
|
1091 | 1083 | // RITA: Perhaps add a few words after "Excellent" to explain what you're doing?
|
1092 |
| -Excellent: |
| 1084 | +Excellent! Let's commit our progress: |
1093 | 1085 |
|
1094 | 1086 | [subs="specialcharacters,quotes"]
|
1095 | 1087 | ----
|
1096 | 1088 | $ *git commit -am "Refactor hard-coded URLs out of templates"*
|
1097 | 1089 | ----
|
1098 | 1090 | // RITA: Please add a sentence to give the figure context. "Let's remove the item from our scratchpad."
|
| 1091 | +And don't forget to cross off the "Remove hardcoded URL..." task as well: |
1099 | 1092 | [role="scratchpad"]
|
1100 | 1093 | *****
|
1101 | 1094 | * 'Remove hardcoded URLs from views.py'
|
|
0 commit comments