I have the following type definitions in my .bolt file called tasks.bolt
//...
type Channel {
name: ShortNonEmptyString,
tasks: Map<TaskId, Task>,
members: Map<UserId, User>
}
type User {
displayName: ShortNonEmptyString,
tasks: Map<UserId, Task>,
channels: Map<ChannelId, Channel>
}
type ChannelId extends String {
validate() { this.length <= 20 }
}
type TaskId extends String {
validate() { this.length <= 20 }
}
type UserId extends String {
//XXX: min. max. length of the user's ID?
validate() { this.length >= 10 }
}
type Percent {
validate() { this >= 0 && this <= 1 }
}
type State {
//TODO: check in client
validate() { this >= 0 && this <= 3 }
}
type ShortNonEmptyString extends String {
validate() { this.length > 0 && this.length < 16}
}
//...
After compiling (firebase-bolt < tasks.bolt), the output contains the followings:
"channels": {
"$key4": {
".validate": "$key4.length <= 20 && ***TYPE RECURSION***"
},
".validate": "newData.hasChildren()"
}
I understand it's a recursion because type Channel has Users and Users has Channels. Is this the normal behavior of the bolt compiler? Is my type definition correct? Is my approach good?
Thank you for your help!