Recall & Review
beginner
What are Firebase data validation rules?
Firebase data validation rules are conditions set to check if data being written to the database is correct and safe before saving it.
Click to reveal answer
beginner
Why is data validation important in Firebase?
Data validation helps prevent bad or harmful data from entering the database, keeping the app reliable and secure.
Click to reveal answer
intermediate
How do you write a simple Firebase rule to allow only strings for a field called 'name'?
Use the rule: <br>
"name": { ".validate": "newData.isString()" } <br> This checks that the new data for 'name' is a string.Click to reveal answer
beginner
What does
newData.exists() check in Firebase rules?It checks if the new data being written actually exists (is not null or deleted).
Click to reveal answer
intermediate
How can you restrict a number field 'age' to be between 0 and 120 in Firebase rules?
Use: <br>
"age": { ".validate": "newData.isNumber() && newData.val() >= 0 && newData.val() <= 120" }Click to reveal answer
What does Firebase data validation rules do?
✗ Incorrect
Firebase validation rules check if data meets set conditions before saving it.
Which function checks if new data is a string in Firebase rules?
✗ Incorrect
newData.isString() returns true if the new data is a string.How do you ensure a field 'score' is a number greater than or equal to zero?
✗ Incorrect
This rule checks that 'score' is a number and not negative.
What happens if data does not pass Firebase validation rules?
✗ Incorrect
Firebase rejects any data that fails validation rules.
Which of these is NOT a valid Firebase validation function?
✗ Incorrect
newData.isDate() is not a valid Firebase validation function.Explain how Firebase data validation rules help keep your database safe and reliable.
Think about what happens if wrong data is saved.
You got /3 concepts.
Describe how to write a Firebase rule that only allows numbers between 1 and 100 for a field called 'rating'.
Use logical AND to combine checks.
You got /4 concepts.