Skip to content

Commit 5bbded2

Browse files
committed
Correctly json_encode validation errors.
1 parent 05d2a6d commit 5bbded2

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

app/Repositories/APIRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function create(array $data)
141141
// Run validator, throw catchable and displayable exception if it fails.
142142
// Exception includes a JSON result of failed validation rules.
143143
if ($validator->fails()) {
144-
throw new DisplayValidationException($validator->errors());
144+
throw new DisplayValidationException(json_encode($validator->errors()));
145145
}
146146

147147
DB::beginTransaction();

app/Repositories/NodeRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function create(array $data)
6060
// Run validator, throw catchable and displayable exception if it fails.
6161
// Exception includes a JSON result of failed validation rules.
6262
if ($validator->fails()) {
63-
throw new DisplayValidationException($validator->errors());
63+
throw new DisplayValidationException(json_encode($validator->errors()));
6464
}
6565

6666
// Verify the FQDN if using SSL
@@ -109,7 +109,7 @@ public function update($id, array $data)
109109
// Run validator, throw catchable and displayable exception if it fails.
110110
// Exception includes a JSON result of failed validation rules.
111111
if ($validator->fails()) {
112-
throw new DisplayValidationException($validator->errors());
112+
throw new DisplayValidationException(json_encode($validator->errors()));
113113
}
114114

115115
// Verify the FQDN
@@ -193,7 +193,7 @@ public function addAllocations($id, array $data)
193193
]);
194194

195195
if ($validator->fails()) {
196-
throw new DisplayValidationException($validator->errors());
196+
throw new DisplayValidationException(json_encode($validator->errors()));
197197
}
198198

199199
$explode = explode('/', $data['allocation_ip']);

app/Repositories/OptionRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function create(array $data)
5858
]);
5959

6060
if ($validator->fails()) {
61-
throw new DisplayValidationException($validator->errors());
61+
throw new DisplayValidationException(json_encode($validator->errors()));
6262
}
6363

6464
if (isset($data['config_from'])) {
@@ -141,7 +141,7 @@ public function update($id, array $data)
141141
});
142142

143143
if ($validator->fails()) {
144-
throw new DisplayValidationException($validator->errors());
144+
throw new DisplayValidationException(json_encode($validator->errors()));
145145
}
146146

147147
if (isset($data['config_from'])) {

app/Repositories/ServerRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function create(array $data)
114114
// Run validator, throw catchable and displayable exception if it fails.
115115
// Exception includes a JSON result of failed validation rules.
116116
if ($validator->fails()) {
117-
throw new DisplayValidationException($validator->errors());
117+
throw new DisplayValidationException(json_encode($validator->errors()));
118118
}
119119

120120
$user = Models\User::findOrFail($data['user_id']);
@@ -360,7 +360,7 @@ public function updateDetails($id, array $data)
360360
// Run validator, throw catchable and displayable exception if it fails.
361361
// Exception includes a JSON result of failed validation rules.
362362
if ($validator->fails()) {
363-
throw new DisplayValidationException($validator->errors());
363+
throw new DisplayValidationException(json_encode($validator->errors()));
364364
}
365365

366366
DB::beginTransaction();
@@ -437,7 +437,7 @@ public function updateContainer($id, array $data)
437437
// Run validator, throw catchable and displayable exception if it fails.
438438
// Exception includes a JSON result of failed validation rules.
439439
if ($validator->fails()) {
440-
throw new DisplayValidationException($validator->errors());
440+
throw new DisplayValidationException(json_encode($validator->errors()));
441441
}
442442

443443
DB::beginTransaction();
@@ -492,7 +492,7 @@ public function changeBuild($id, array $data)
492492
// Run validator, throw catchable and displayable exception if it fails.
493493
// Exception includes a JSON result of failed validation rules.
494494
if ($validator->fails()) {
495-
throw new DisplayValidationException($validator->errors());
495+
throw new DisplayValidationException(json_encode($validator->errors()));
496496
}
497497

498498
DB::beginTransaction();

app/Repositories/ServiceRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function create(array $data)
4848
]);
4949

5050
if ($validator->fails()) {
51-
throw new DisplayValidationException($validator->errors());
51+
throw new DisplayValidationException(json_encode($validator->errors()));
5252
}
5353

5454
return DB::transaction(function () use ($data) {
@@ -94,7 +94,7 @@ public function update($id, array $data)
9494
]);
9595

9696
if ($validator->fails()) {
97-
throw new DisplayValidationException($validator->errors());
97+
throw new DisplayValidationException(json_encode($validator->errors()));
9898
}
9999

100100
return DB::transaction(function () use ($data, $service) {

app/Repositories/UserRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function create(array $data)
6767
// Run validator, throw catchable and displayable exception if it fails.
6868
// Exception includes a JSON result of failed validation rules.
6969
if ($validator->fails()) {
70-
throw new DisplayValidationException($validator->errors());
70+
throw new DisplayValidationException(json_encode($validator->errors()));
7171
}
7272

7373
DB::beginTransaction();
@@ -141,7 +141,7 @@ public function update($id, array $data)
141141
// Run validator, throw catchable and displayable exception if it fails.
142142
// Exception includes a JSON result of failed validation rules.
143143
if ($validator->fails()) {
144-
throw new DisplayValidationException($validator->errors());
144+
throw new DisplayValidationException(json_encode($validator->errors()));
145145
}
146146

147147
// The password and root_admin fields are not mass assignable.

app/Repositories/VariableRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function create($option, array $data)
6363
});
6464

6565
if ($validator->fails()) {
66-
throw new DisplayValidationException($validator->errors());
66+
throw new DisplayValidationException(json_encode($validator->errors()));
6767
}
6868

6969
if (isset($data['env_variable'])) {
@@ -137,7 +137,7 @@ public function update($id, array $data)
137137
});
138138

139139
if ($validator->fails()) {
140-
throw new DisplayValidationException($validator->errors());
140+
throw new DisplayValidationException(json_encode($validator->errors()));
141141
}
142142

143143
if (isset($data['env_variable'])) {

0 commit comments

Comments
 (0)