Firestore安全规则检查字段是否为整数 [英] firestore security rule check if a field is an integer
本文介绍了Firestore安全规则检查字段是否为整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何检查字段是否为整数.我知道我们可以使用 int(request.resource.data [field])
将字段条目转换为整数,但是有一种方法可以检查 request.resource.data[field]
是一个整数,如果是则返回true,否则返回false?
I am wondering how do I check if a field is an integer or not. I know that we are able to convert a field entry to an integer with int(request.resource.data[field])
, but is there a way to check if request.resource.data[field]
is an integer, return true if it is, and false it isn't?
推荐答案
您可以使用 is
运算符检查类型.
You can check for type with the is
operator.
所以:
request.resource.data[field] is int
或
request.resource.data.field is int
我强烈建议您在 Firebase安全规则中的数据类型和全局对象中查看Doug的视频在检查类型上.
I highly recommend checking out Doug's video on Data types and global objects in Firebase security rules, specifically the section on checking types.
这篇关于Firestore安全规则检查字段是否为整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文