Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore Rules - Datatype Validation

I've read multiple questions in Stack Overflow and the documentation but I couldn't find multiple validations that I can imagine that exist.

Per example, it is possible to check if request.resource.data.description is string but can is it possible to do the same when it comes to number, float, timestamp or even array/list? I couldn't even find the string one in the documentation so I can imagine it is missing more than just that one.

like image 825
André Avatar asked Sep 20 '19 16:09

André


People also ask

How do I check my firestore rules?

Open the Firebase console and select your project. Then, from the product navigation, do one of the following: Select Realtime Database, Cloud Firestore, or Storage, as appropriate, then click Rules to navigate to the Rules editor.

How do I test firestore rules locally?

Use the @firebase/rules-unit-testing module to interact with the emulator that runs locally. If you get timeouts or ECONNREFUSED errors, double-check that the emulator is actually running. We strongly recommend using a recent version of Node. js so you can use async/await notation.

Do firestore rules apply to cloud functions?

The service cloud. firestore declaration scopes the rules to Firestore, preventing conflicts between Firestore Security Rules and rules for other products such as Cloud Storage. The match /databases/{database}/documents declaration specifies that rules should match any Firestore database in the project.


1 Answers

You might want to watch my video on data types in Firebase security rules. In it, I list all the different data types that you can check:

value is bool
value is int
value is float
value is number
value is string

value is list
value is map

value is timestamp
value is duration
value is path
value is latlng
like image 189
Doug Stevenson Avatar answered Oct 21 '22 05:10

Doug Stevenson