在实时 Firebase 数据库中,这是我的数据结构:
{'comments': {
${project_uuid}: {
${thread_uuid}: {
'author': 12,
'data': 'who lot of text'
}
}
}}
我想验证
comments
内部只有uuid对象。我使用 bolt 生成 Firebase 规则:
path /comments {
read() { auth != null }
write() { auth != null }
/{project_uuid} is UuidOnly {
/{thread_uuid} is Thread;
}
}
type Thread {
author: Number,
data: String,
}
type UuidOnly {
validate() {
// The next line is the problem
this.parent().key().test(/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/)
}
}
在最后一行中,
key()
似乎无法用作函数。我如何进行此验证以确保注释内只有 uuid 对象?
问候尼克,请尝试以下操作
type UuidOnly {
validate() {
data.test(/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/)
}
}
尝试上述方法并告诉我