Skip to content

Commit 6508e0d

Browse files
committed
Start adding spec validation
1 parent 2b0c31e commit 6508e0d

25 files changed

+2216
-33
lines changed

resources/lang/en/errors.php

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
/**
3+
* Copyright 2020 Cloud Creativity Limited
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
return [
19+
20+
/*
21+
|--------------------------------------------------------------------------
22+
| Error Object Language Lines
23+
|--------------------------------------------------------------------------
24+
|
25+
| The following language lines contain the default translatable members
26+
| of JSON API error objects. According to the JSON API spec, the
27+
| `title` and `detail` members can be localized. In addition the `code`
28+
| member is also read from this package if you want to give the error
29+
| a specific code.
30+
|
31+
| Set any value to an empty string if you do not want the member to be
32+
| included in the error object.
33+
|
34+
| @see http://jsonapi.org/format/#errors
35+
*/
36+
37+
'unauthorized' => [
38+
'title' => 'Unauthenticated',
39+
'detail' => '',
40+
'code' => '',
41+
],
42+
43+
'forbidden' => [
44+
'title' => 'Unauthorized',
45+
'detail' => '',
46+
'code' => '',
47+
],
48+
49+
'token_mismatch' => [
50+
'title' => 'Invalid Token',
51+
'detail' => 'The token is not valid.',
52+
'code' => '',
53+
],
54+
55+
'member_required' => [
56+
'title' => 'Non-Compliant JSON API Document',
57+
'detail' => 'The member :member is required.',
58+
'code' => '',
59+
],
60+
61+
'member_object_expected' => [
62+
'title' => 'Non-Compliant JSON API Document',
63+
'detail' => 'The member :member must be an object.',
64+
'code' => '',
65+
],
66+
67+
'member_identifier_expected' => [
68+
'title' => 'Non-Compliant JSON API Document',
69+
'detail' => 'The member :member must be a resource identifier.',
70+
'code' => '',
71+
],
72+
73+
'member_string_expected' => [
74+
'title' => 'Non-Compliant JSON API Document',
75+
'detail' => 'The member :member must be a string.',
76+
'code' => '',
77+
],
78+
79+
'member_empty' => [
80+
'title' => 'Non-Compliant JSON API Document',
81+
'detail' => 'The member :member cannot be empty.',
82+
'code' => '',
83+
],
84+
85+
'member_field_not_allowed' => [
86+
'title' => 'Non-Compliant JSON API Document',
87+
'detail' => 'The member :member cannot have a :field field.',
88+
'code' => '',
89+
],
90+
91+
'resource_type_not_supported' => [
92+
'title' => 'Not Supported',
93+
'detail' => 'Resource type :type is not supported by this endpoint.',
94+
'code' => '',
95+
],
96+
97+
'resource_type_not_recognised' => [
98+
'title' => 'Not Supported',
99+
'detail' => 'Resource type :type is not recognised.',
100+
'code' => '',
101+
],
102+
103+
'resource_id_not_supported' => [
104+
'title' => 'Not Supported',
105+
'detail' => 'Resource id :id is not supported by this endpoint.',
106+
'code' => '',
107+
],
108+
109+
'resource_client_ids_not_supported' => [
110+
'title' => 'Not Supported',
111+
'detail' => 'Resource type :type does not support client-generated IDs.',
112+
'code' => '',
113+
],
114+
115+
'resource_exists' => [
116+
'title' => 'Conflict',
117+
'detail' => 'Resource :id already exists.',
118+
'code' => '',
119+
],
120+
121+
'resource_not_found' => [
122+
'title' => 'Not Found',
123+
'detail' => 'The related resource does not exist.',
124+
'code' => '',
125+
],
126+
127+
'resource_field_exists_in_attributes_and_relationships' => [
128+
'title' => 'Non-Compliant JSON API Document',
129+
'detail' => 'The :field field cannot exist as an attribute and a relationship.',
130+
'code' => '',
131+
],
132+
133+
'resource_invalid' => [
134+
'title' => 'Unprocessable Entity',
135+
'detail' => 'The document was well-formed but contains semantic errors.',
136+
'code' => '',
137+
],
138+
139+
'resource_cannot_be_deleted' => [
140+
'title' => 'Not Deletable',
141+
'detail' => 'The resource cannot be deleted.',
142+
'code' => '',
143+
],
144+
145+
'query_invalid' => [
146+
'title' => 'Invalid Query Parameter',
147+
'detail' => 'The request query parameters are invalid.',
148+
'code' => '',
149+
],
150+
151+
'failed_validator' => [
152+
'title' => 'Unprocessable Entity',
153+
'detail' => 'The document was well-formed but contains semantic errors.',
154+
'code' => '',
155+
],
156+
];

resources/lang/en/validation.php

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Copyright 2020 Cloud Creativity Limited
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
return [
19+
20+
/*
21+
|--------------------------------------------------------------------------
22+
| Validation Language Lines
23+
|--------------------------------------------------------------------------
24+
|
25+
| The following language lines contain the default error messages used by
26+
| the validation rules for this package.
27+
|
28+
*/
29+
30+
'allowed_field_sets' => [
31+
'default' => 'Sparse field sets must contain only allowed ones.',
32+
'singular' => 'Sparse field set :values is not allowed.',
33+
'plural' => 'Sparse field sets :values are not allowed.',
34+
],
35+
36+
'allowed_filter_parameters' => [
37+
'default' => 'Filter parameters must contain only allowed ones.',
38+
'singular' => 'Filter parameter :values is not allowed.',
39+
'plural' => 'Filter parameters :values are not allowed.',
40+
],
41+
42+
'allowed_include_paths' => [
43+
'default' => 'Include paths must contain only allowed ones.',
44+
'singular' => 'Include path :values is not allowed.',
45+
'plural' => 'Include paths :values are not allowed.',
46+
],
47+
48+
'allowed_sort_parameters' => [
49+
'default' => 'Sort parameters must contain only allowed ones.',
50+
'singular' => 'Sort parameter :values is not allowed.',
51+
'plural' => 'Sort parameters :values are not allowed.',
52+
],
53+
54+
'allowed_page_parameters' => [
55+
'default' => 'Page parameters must contain only allowed ones.',
56+
'singular' => 'Page parameter :values is not allowed.',
57+
'plural' => 'Page parameters :values are not allowed.',
58+
],
59+
60+
'date_time_iso_8601' => 'The :attribute is not a valid ISO 8601 date and time.',
61+
62+
'disallowed_parameter' => 'Parameter :name is not allowed.',
63+
64+
'has_one' => 'The :attribute field must be a to-one relationship containing :types resources.',
65+
66+
'has_many' => 'The :attribute field must be a to-many relationship containing :types resources.',
67+
];

resources/lang/nl/errors.php

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
/**
3+
* Copyright 2020 Cloud Creativity Limited
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
return [
19+
20+
/*
21+
|--------------------------------------------------------------------------
22+
| Error Object Language Lines
23+
|--------------------------------------------------------------------------
24+
|
25+
| The following language lines contain the default translatable members
26+
| of JSON API error objects. According to the JSON API spec, the
27+
| `title` and `detail` members can be localized. In addition the `code`
28+
| member is also read from this package if you want to give the error
29+
| a specific code.
30+
|
31+
| Set any value to an empty string if you do not want the member to be
32+
| included in the error object.
33+
|
34+
| @see http://jsonapi.org/format/#errors
35+
*/
36+
37+
'unauthorized' => [
38+
'title' => 'Ongeauthenticeerd',
39+
'detail' => '',
40+
'code' => '',
41+
],
42+
43+
'forbidden' => [
44+
'title' => 'Ongeautoriseerd',
45+
'detail' => '',
46+
'code' => '',
47+
],
48+
49+
'token_mismatch' => [
50+
'title' => 'Ongeldig Token',
51+
'detail' => 'Het token is niet geldig.',
52+
'code' => '',
53+
],
54+
55+
'member_required' => [
56+
'title' => 'Niet-Conform JSON API Document',
57+
'detail' => 'Het onderdeel :member is vereist.',
58+
'code' => '',
59+
],
60+
61+
'member_object_expected' => [
62+
'title' => 'Niet-Conform JSON API Document',
63+
'detail' => 'Het onderdeel :member moet een object zijn.',
64+
'code' => '',
65+
],
66+
67+
'member_identifier_expected' => [
68+
'title' => 'Niet-Conform JSON API Document',
69+
'detail' => 'Het onderdeel :member moet een resource identifier zijn.',
70+
'code' => '',
71+
],
72+
73+
'member_string_expected' => [
74+
'title' => 'Niet-Conform JSON API Document',
75+
'detail' => 'Het onderdeel :member moet een string zijn.',
76+
'code' => '',
77+
],
78+
79+
'member_empty' => [
80+
'title' => 'Niet-Conform JSON API Document',
81+
'detail' => 'Het onderdeel :member kan niet leeg zijn.',
82+
'code' => '',
83+
],
84+
85+
'member_field_not_allowed' => [
86+
'title' => 'Niet-Conform JSON API Document',
87+
'detail' => 'Het onderdeel :member kan niet een veld :field hebben.',
88+
'code' => '',
89+
],
90+
91+
'resource_type_not_supported' => [
92+
'title' => 'Niet Ondersteund',
93+
'detail' => 'Resource type :type wordt niet ondersteund door dit endpoint.',
94+
'code' => '',
95+
],
96+
97+
'resource_type_not_recognised' => [
98+
'title' => 'Niet Ondersteund',
99+
'detail' => 'Resource type :type wordt niet herkend.',
100+
'code' => '',
101+
],
102+
103+
'resource_id_not_supported' => [
104+
'title' => 'Niet Ondersteund',
105+
'detail' => 'Resource id :id wordt niet ondersteund door dit endpoint.',
106+
'code' => '',
107+
],
108+
109+
'resource_client_ids_not_supported' => [
110+
'title' => 'Niet Ondersteund',
111+
'detail' => 'Resource type :type ondersteunt geen client-gegenereerde IDs.',
112+
'code' => '',
113+
],
114+
115+
'resource_exists' => [
116+
'title' => 'Conflict',
117+
'detail' => 'Resource :id bestaat al.',
118+
'code' => '',
119+
],
120+
121+
'resource_not_found' => [
122+
'title' => 'Niet gevonden',
123+
'detail' => 'De gerelateerde resource bestaat niet.',
124+
'code' => '',
125+
],
126+
127+
'resource_field_exists_in_attributes_and_relationships' => [
128+
'title' => 'Niet-Conform JSON API Document',
129+
'detail' => 'Het veld :field kan niet bestaan als een attribuut en een relatie.',
130+
'code' => '',
131+
],
132+
133+
'resource_invalid' => [
134+
'title' => 'Onverwerkbare Entiteit',
135+
'detail' => 'Het document was goed opgemaakt, maar bevat semantische fouten.',
136+
'code' => '',
137+
],
138+
139+
'resource_cannot_be_deleted' => [
140+
'title' => 'Niet Verwijderbaar',
141+
'detail' => 'Deze resource kan niet worden verwijderd.',
142+
'code' => '',
143+
],
144+
145+
'query_invalid' => [
146+
'title' => 'Ongeldige queryparameter',
147+
'detail' => 'De queryparameters van het verzoek zijn ongeldig.',
148+
'code' => '',
149+
],
150+
151+
'failed_validator' => [
152+
'title' => 'Onverwerkbare Entiteit',
153+
'detail' => 'Het document was goed opgemaakt, maar bevat semantische fouten.',
154+
'code' => '',
155+
],
156+
];

0 commit comments

Comments
 (0)