Recall & Review
beginner
What is the purpose of sanitization methods in Express?
Sanitization methods clean user input to remove harmful or unwanted characters, helping prevent security issues like injection attacks.
Click to reveal answer
beginner
Name a popular Express middleware used for sanitizing input data.
express-validator is a popular middleware that provides sanitization and validation methods for Express applications.
Click to reveal answer
beginner
How does the .trim() sanitization method work in express-validator?
The .trim() method removes whitespace from both ends of a string, making input cleaner and more consistent.
Click to reveal answer
intermediate
What does the .escape() sanitization method do?
The .escape() method replaces HTML special characters like <, >, &, ' and " with their safe encoded equivalents to prevent HTML injection.
Click to reveal answer
intermediate
Why should you use sanitization methods along with validation in Express apps?
Validation checks if input meets rules (like length or format), while sanitization cleans the input to remove harmful parts. Using both keeps data safe and reliable.
Click to reveal answer
Which Express middleware is commonly used for sanitizing user input?
✗ Incorrect
express-validator provides both validation and sanitization methods for Express apps.
What does the .trim() method do in sanitization?
✗ Incorrect
.trim() removes spaces or tabs from the start and end of the input string.
Why is .escape() important in sanitization?
✗ Incorrect
.escape() replaces characters like < and > with safe codes to avoid HTML injection.
Which of these is NOT a sanitization method in express-validator?
✗ Incorrect
.isEmail() is a validation method, not sanitization.
What is the main goal of sanitization in Express apps?
✗ Incorrect
Sanitization cleans input to keep the app safe from attacks and errors.
Explain how sanitization methods help keep an Express app secure.
Think about how bad input can cause problems and how cleaning it helps.
You got /4 concepts.
List and describe three common sanitization methods used in express-validator.
Focus on methods that clean strings and make input safe.
You got /3 concepts.