| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package JMAP::Validation::Checks::ContactGroup; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
10086
|
use JMAP::Validation; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
108
|
|
|
4
|
4
|
|
|
4
|
|
1435
|
use JMAP::Validation::Checks::String; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
111
|
|
|
5
|
4
|
|
|
4
|
|
1352
|
use JMAP::Validation::Tests::ContactGroup; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
73
|
|
|
6
|
4
|
|
|
4
|
|
14
|
use JMAP::Validation::Tests::Object; |
|
|
4
|
|
|
|
|
34
|
|
|
|
4
|
|
|
|
|
52
|
|
|
7
|
4
|
|
|
4
|
|
1164
|
use JMAP::Validation::Tests::SetError; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
82
|
|
|
8
|
4
|
|
|
4
|
|
14
|
use JMAP::Validation::Tests::String; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
43
|
|
|
9
|
4
|
|
|
4
|
|
1364
|
use JSON::Typist; |
|
|
4
|
|
|
|
|
11463
|
|
|
|
4
|
|
|
|
|
85
|
|
|
10
|
4
|
|
|
4
|
|
19
|
use Test2::Bundle::Extended; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
20
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# record types {{{ |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $typist = JSON::Typist->new(); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %ContactGroup_checks = ( |
|
17
|
|
|
|
|
|
|
id => $JMAP::Validation::Checks::String::is_id, |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
name => check_set( |
|
20
|
|
|
|
|
|
|
$JMAP::Validation::Checks::String::is_string, |
|
21
|
|
|
|
|
|
|
$JMAP::Validation::Checks::String::has_at_least_one_character, |
|
22
|
|
|
|
|
|
|
$JMAP::Validation::Checks::String::has_at_most_256_bytes, |
|
23
|
|
|
|
|
|
|
), |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
contactIds => $JMAP::Validation::Checks::String::is_array_of_ids, |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $is_ContactGroup = hash { |
|
29
|
|
|
|
|
|
|
field id => $ContactGroup_checks{id}; |
|
30
|
|
|
|
|
|
|
field name => $ContactGroup_checks{name}; |
|
31
|
|
|
|
|
|
|
field contactIds => $ContactGroup_checks{contactIds}; |
|
32
|
|
|
|
|
|
|
end(); |
|
33
|
|
|
|
|
|
|
}; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $is_ContactGroup_for_create = hash { |
|
36
|
|
|
|
|
|
|
field name => $ContactGroup_checks{name}; |
|
37
|
|
|
|
|
|
|
field contactIds => $ContactGroup_checks{contactIds}; |
|
38
|
|
|
|
|
|
|
end(); |
|
39
|
|
|
|
|
|
|
}; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our $is_ContactGroup_for_update = hash{ |
|
42
|
|
|
|
|
|
|
field name => in_set($ContactGroup_checks{name}, U()); |
|
43
|
|
|
|
|
|
|
field contactIds => in_set($ContactGroup_checks{contactIds}, U()); |
|
44
|
|
|
|
|
|
|
end(); |
|
45
|
|
|
|
|
|
|
}; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# }} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# requests {{{ |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
our $getContactGroups_args = hash { |
|
52
|
|
|
|
|
|
|
field accountId => validator(sub { |
|
53
|
|
|
|
|
|
|
my (%params) = @_; |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
if (defined $params{got}) { |
|
56
|
|
|
|
|
|
|
return unless JMAP::Validation::validate( |
|
57
|
|
|
|
|
|
|
$params{got}, |
|
58
|
|
|
|
|
|
|
$JMAP::Validation::Checks::String::is_string |
|
59
|
|
|
|
|
|
|
); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
return 1; |
|
63
|
|
|
|
|
|
|
}); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
field ids => validator(sub { |
|
66
|
|
|
|
|
|
|
my (%params) = @_; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
if (defined $params{got}) { |
|
69
|
|
|
|
|
|
|
return unless JMAP::Validation::validate( |
|
70
|
|
|
|
|
|
|
$params{got}, |
|
71
|
|
|
|
|
|
|
$JMAP::Validation::Checks::String::is_array_of_ids, |
|
72
|
|
|
|
|
|
|
); |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
return 1; |
|
76
|
|
|
|
|
|
|
}); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
end(); |
|
79
|
|
|
|
|
|
|
}; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
our $setContactGroups_args = hash { |
|
82
|
|
|
|
|
|
|
field accountId => in_set($JMAP::Validation::Checks::String::is_string_or_null, U()); |
|
83
|
|
|
|
|
|
|
field ifInState => in_set($JMAP::Validation::Checks::String::is_string_or_null, U()); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
field create => in_set( |
|
86
|
|
|
|
|
|
|
hash{ |
|
87
|
|
|
|
|
|
|
all_keys validator(sub { |
|
88
|
|
|
|
|
|
|
my %params = @_; |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
return JMAP::Validation::validate( |
|
91
|
|
|
|
|
|
|
$typist->apply_types($params{got}), |
|
92
|
|
|
|
|
|
|
$JMAP::Validation::Checks::String::is_id, |
|
93
|
|
|
|
|
|
|
); |
|
94
|
|
|
|
|
|
|
}); |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
all_values $is_ContactGroup_for_create; |
|
97
|
|
|
|
|
|
|
}, |
|
98
|
|
|
|
|
|
|
U(), |
|
99
|
|
|
|
|
|
|
); |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
field update => in_set( |
|
102
|
|
|
|
|
|
|
hash{ |
|
103
|
|
|
|
|
|
|
all_keys validator(sub { |
|
104
|
|
|
|
|
|
|
my %params = @_; |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return JMAP::Validation::validate( |
|
107
|
|
|
|
|
|
|
$typist->apply_types($params{got}), |
|
108
|
|
|
|
|
|
|
$JMAP::Validation::Checks::String::is_id, |
|
109
|
|
|
|
|
|
|
); |
|
110
|
|
|
|
|
|
|
}); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
all_values $is_ContactGroup_for_update; |
|
113
|
|
|
|
|
|
|
}, |
|
114
|
|
|
|
|
|
|
U(), |
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
field destroy => in_set(array { all_items $JMAP::Validation::Checks::String::is_id }, U()); |
|
118
|
|
|
|
|
|
|
end(); |
|
119
|
|
|
|
|
|
|
}; |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# }}} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
# response types {{{ |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
our $is_contactGroups = hash { |
|
126
|
|
|
|
|
|
|
field accountId => $JMAP::Validation::Checks::String::is_id; |
|
127
|
|
|
|
|
|
|
field state => $JMAP::Validation::Checks::String::is_string; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# TODO: https://github.com/Test-More/Test2-Suite/issues/9 |
|
130
|
|
|
|
|
|
|
# field list => array { all_items($is_ContactGroup) }; |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
field list => array{ |
|
133
|
|
|
|
|
|
|
filter_items { grep { ! JMAP::Validation::Tests::ContactGroup::is_ContactGroup($_) } @_ }; |
|
134
|
|
|
|
|
|
|
end(); |
|
135
|
|
|
|
|
|
|
}; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
field notFound => validator(sub { |
|
138
|
|
|
|
|
|
|
my (%params) = @_; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
if (defined $params{got}) { |
|
141
|
|
|
|
|
|
|
return unless JMAP::Validation::validate( |
|
142
|
|
|
|
|
|
|
$params{got}, |
|
143
|
|
|
|
|
|
|
array { |
|
144
|
|
|
|
|
|
|
filter_items { grep { ! JMAP::Validation::Tests::String::is_string($_) } @_ }; |
|
145
|
|
|
|
|
|
|
end(); |
|
146
|
|
|
|
|
|
|
}, |
|
147
|
|
|
|
|
|
|
); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
return 1; |
|
151
|
|
|
|
|
|
|
}); |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
end(); |
|
154
|
|
|
|
|
|
|
}; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
our $is_contactGroupUpdates = hash { |
|
157
|
|
|
|
|
|
|
field accountId => $JMAP::Validation::Checks::String::is_id; |
|
158
|
|
|
|
|
|
|
field oldState => $JMAP::Validation::Checks::String::is_string; |
|
159
|
|
|
|
|
|
|
field newState => $JMAP::Validation::Checks::String::is_string; |
|
160
|
|
|
|
|
|
|
field changed => $JMAP::Validation::Checks::String::is_array_of_ids; |
|
161
|
|
|
|
|
|
|
field removed => $JMAP::Validation::Checks::String::is_array_of_ids; |
|
162
|
|
|
|
|
|
|
end(); |
|
163
|
|
|
|
|
|
|
}; |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
our $is_contactGroupsSet = hash { |
|
166
|
|
|
|
|
|
|
field accountId => $JMAP::Validation::Checks::String::is_id; |
|
167
|
|
|
|
|
|
|
field oldState => $JMAP::Validation::Checks::String::is_string_or_null; |
|
168
|
|
|
|
|
|
|
# TODO: field newState => $JMAP::Validation::Checks::String::is_string; |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
field created => check_set( |
|
171
|
|
|
|
|
|
|
hash {}, |
|
172
|
|
|
|
|
|
|
validator(sub { |
|
173
|
|
|
|
|
|
|
my (%params) = @_; |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
foreach my $createdId (keys %{$params{got}}) { |
|
176
|
|
|
|
|
|
|
return unless JMAP::Validation::Tests::Object::is_object($params{got}{$createdId}); |
|
177
|
|
|
|
|
|
|
return unless scalar(keys %{$params{got}{$createdId}}) == 1; |
|
178
|
|
|
|
|
|
|
return unless JMAP::Validation::Tests::String::is_id($params{got}{$createdId}{id}); |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
return 1; |
|
182
|
|
|
|
|
|
|
}), |
|
183
|
|
|
|
|
|
|
); |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
field updated => $JMAP::Validation::Checks::String::is_array_of_ids; |
|
186
|
|
|
|
|
|
|
field destroyed => $JMAP::Validation::Checks::String::is_array_of_ids; |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
field notCreated => check_set( |
|
189
|
|
|
|
|
|
|
hash {}, |
|
190
|
|
|
|
|
|
|
validator(sub { |
|
191
|
|
|
|
|
|
|
my (%params) = @_; |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
foreach my $creationId (keys %{$params{got}}) { |
|
194
|
|
|
|
|
|
|
return unless JMAP::Validation::Tests::SetError::is_SetError_invalidProperties( |
|
195
|
|
|
|
|
|
|
$params{got}{$creationId}, qw{name contactIds}, |
|
196
|
|
|
|
|
|
|
); |
|
197
|
|
|
|
|
|
|
} |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
return 1; |
|
200
|
|
|
|
|
|
|
}), |
|
201
|
|
|
|
|
|
|
); |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
field notUpdated => check_set( |
|
204
|
|
|
|
|
|
|
hash {}, |
|
205
|
|
|
|
|
|
|
validator(sub { |
|
206
|
|
|
|
|
|
|
my (%params) = @_; |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
foreach my $updatedId (keys %{$params{got}}) { |
|
209
|
|
|
|
|
|
|
my $is_notFound = JMAP::Validation::Tests::SetError::is_SetError_notFound( |
|
210
|
|
|
|
|
|
|
$params{got}{$updatedId} |
|
211
|
|
|
|
|
|
|
); |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
my $is_invalidProperties = JMAP::Validation::Tests::SetError::is_SetError_invalidProperties( |
|
214
|
|
|
|
|
|
|
$params{got}{$updatedId}, qw{name contactIds}, |
|
215
|
|
|
|
|
|
|
); |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
return unless ($is_notFound or $is_invalidProperties); |
|
218
|
|
|
|
|
|
|
} |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
return 1; |
|
221
|
|
|
|
|
|
|
}), |
|
222
|
|
|
|
|
|
|
); |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
field notDestroyed => check_set( |
|
225
|
|
|
|
|
|
|
hash {}, |
|
226
|
|
|
|
|
|
|
validator(sub { |
|
227
|
|
|
|
|
|
|
my (%params) = @_; |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
foreach my $destroyedId (keys %{$params{got}}) { |
|
230
|
|
|
|
|
|
|
return unless JMAP::Validation::Tests::SetError::is_SetError_notFound( |
|
231
|
|
|
|
|
|
|
$params{got}{$destroyedId} |
|
232
|
|
|
|
|
|
|
); |
|
233
|
|
|
|
|
|
|
} |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
return 1; |
|
236
|
|
|
|
|
|
|
}), |
|
237
|
|
|
|
|
|
|
); |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# TODO: end(); once newState works |
|
240
|
|
|
|
|
|
|
}; |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
# }}} |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
1; |