【发布时间】:2018-06-23 10:06:19
【问题描述】:
我的实际验证如下:
".write": true,
".validate": "newData.child('name').isString()
&& newData.child('surname').isString()
&& newData.child('age').isNumber()",
但是,age 属性是可选。用户可以填写或不填写,取决于他的决定。
我的情况是,如何告诉 firebase age 是可选,但如果它存在(用户填写) - 它必须是一个 数字 ?
Flow 或 TypeScript 中的 maybe type 之类的 (age?: number)
谢谢!:)
【问题讨论】:
-
为什么不在您的客户端javascript中简单地将其设置为
0?换句话说,var userAge = 0. -
@RonRoyston 这是一个黑客。我不想要任何黑客:P
标签: javascript firebase firebase-realtime-database firebase-security