In my chess app I use Firebase.ServerValue.TIMESTAMP
to record the time of a move, e.g.:
{
from: 'e2',
to: 'e4',
playedAt: Firebase.ServerValue.TIMESTAMP
}
How could I validate that playedAt
is Firebase.ServerValue.TIMESTAMP
and not an arbitrary timestamp like 1408663907743?
I expected Firebase Security Rules to have a method like isTimestamp()
that would work similarly to isNumber()
and isString()
, but I couldn't find one.
Timestamps in Firebase, like the one that corresponds to the server side macro Firebase.ServerValue.TIMESTAMP
are stored like any other number. No additional type information is stored that makes them special. So, isTimestamp()
would be equivalent to isNumber()
.
If you'd like to further validate that the timestamp matches the current server time, see this related answer.