Jignesh Ansodariya
Jignesh Ansodariya

Reputation: 12685

How to set datatype validation in Firebase?

I have Firebase data structure like this:

enter image description here

As you can see in the image, the value of OT1, OT1_B, etc. is Integer. Now, I want such a validation that no one can save value of other data-type for this key.

How can set I rule for this kind of restriction?

Upvotes: 2

Views: 1148

Answers (2)

Darshan Soni
Darshan Soni

Reputation: 1809

If you are taking user input for that fields then simply adding ,

android:inputType="numberDecimal"

will do a work for you

Upvotes: 0

Akshay Bhat 'AB'
Akshay Bhat 'AB'

Reputation: 2700

There is a rule available to validate your data in FireBase RealTime Database. Use .validate rule to check if your data is a string or other type and you can also use regular expression to check the matches. Refer the official documentation to check how to Validate Data under section Validating Data.

Upvotes: 2

Related Questions