-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.rules.bolt
110 lines (91 loc) · 2.69 KB
/
database.rules.bolt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
path /volunteers/{uid} is Volunteer {
write() { true }
read() { auth.token.admin == true }
}
path /requesters/{uid} is Requester {
write() { true }
read() { auth.token.admin == true }
}
type Name extends String {
validate() { this.length > 0 && this.length <= 64}
}
type FullName extends String {
validate() { this.length > 0 && this.length <= 128}
}
type NullableEmail extends String {
validate() { this == '' || (this.length > 0 && this.length <= 256 && this.includes("@"))}
}
type Email extends String {
validate() { this.length > 0 && this.length <= 256 && this.includes("@")}
}
type Address extends String {
validate() { this.length > 0 && this.length <= 256 }
}
type Phone extends String {
validate() { this.length > 0 && this.length <= 15 }
}
type HasCar extends Boolean {
validate() { this != null }
}
type TermsAgreement extends Boolean {
validate() { this == true}
}
type List extends String {
validate() { this.length > 0 && this.length <= 1024}
}
type Latitude extends Number {
validate() { this >= -90 && this <= 90 }
}
type Longitude extends Number {
validate() { this >= -180 && this <= 180 }
}
type FulfillmentStatus extends String {
validate() { this == 'new' || this == 'sourcing_volunteer' || this == 'pending_fulfillment' || this == 'fulfilling' || this == 'resolved' }
}
type Resolution extends String {
validate() { this == 'delivered' || this == 'no_volunteer_found' || this == 'requester_not_communicating' || this == 'rejected' || this == 'cancelled' || this == 'duplicate' }
}
type Language extends String[] {
validate() { this.includes('English') || this.includes('Spanish') || this.includes('Mandarin') || this.includes('Cantonese') ||
this.includes('Other')}
}
type Volunteer {
firstName: Name,
lastName: Name,
name: FullName,
email: Email,
address: Address,
phone: Phone,
hasCar: HasCar,
termsAgreement: TermsAgreement,
language: Language,
lat: Latitude | Null,
lng: Longitude | Null,
timestamp: InitialTimestamp
}
type Requester {
firstName: Name,
lastName: Name,
name: FullName,
email: NullableEmail,
address: Address,
phone: Phone,
termsAgreement: TermsAgreement,
list: List,
lat: Latitude | Null,
lng: Longitude | Null,
language: Language,
timestamp: InitialTimestamp,
fulfillment_status: FulfillmentStatus,
resolution: Resolution,
fulfillment_status_timestamp: CurrentTimestamp
}
type CurrentTimestamp extends Number {
validate() { this == now }
}
type InitialTimestamp extends Number {
validate() { initial(this, now) }
}
// Returns true if the value is intialized to init, or if it retains it's prior
// value, otherwise.
initial(value, init) { value == (prior(value) == null ? init : prior(value)) }