But users with emails like 'user@exampleacom' are still allowed. What is the error?
medium
A. matches() does not work in Firebase rules
B. The regex pattern is incorrect; it should escape the dot
C. newData.isString() is missing
D. The rule should use newData.exists() instead
Solution
Step 1: Review the regex pattern used
The pattern '.*@example.com$' treats '.' as any character, not a literal dot.
Step 2: Correct the regex to escape the dot
It should be '.*@example\.com$' to match the literal '.com' ending.
Final Answer:
The regex pattern is incorrect; it should escape the dot -> Option B
Quick Check:
Escape dot in regex = \. [OK]
Hint: Escape dots in regex with double backslash \ [OK]
Common Mistakes:
Not escaping '.' in regex
Thinking matches() is unsupported
Confusing isString() with exists()
5. You want to write a Firebase validation rule for a posts node where each post must have a title (string, max 100 chars) and tags (array of strings, max 5 tags). Which rule correctly enforces this?