Correctly json_encode validation errors.

This commit is contained in:
Dane Everitt 2017-03-16 19:30:04 -04:00
parent 05d2a6d370
commit 5bbded2c03
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
7 changed files with 16 additions and 16 deletions

View File

@ -141,7 +141,7 @@ class APIRepository
// Run validator, throw catchable and displayable exception if it fails. // Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules. // Exception includes a JSON result of failed validation rules.
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
DB::beginTransaction(); DB::beginTransaction();

View File

@ -60,7 +60,7 @@ class NodeRepository
// Run validator, throw catchable and displayable exception if it fails. // Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules. // Exception includes a JSON result of failed validation rules.
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
// Verify the FQDN if using SSL // Verify the FQDN if using SSL
@ -109,7 +109,7 @@ class NodeRepository
// Run validator, throw catchable and displayable exception if it fails. // Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules. // Exception includes a JSON result of failed validation rules.
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
// Verify the FQDN // Verify the FQDN
@ -193,7 +193,7 @@ class NodeRepository
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
$explode = explode('/', $data['allocation_ip']); $explode = explode('/', $data['allocation_ip']);

View File

@ -58,7 +58,7 @@ class OptionRepository
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
if (isset($data['config_from'])) { if (isset($data['config_from'])) {
@ -141,7 +141,7 @@ class OptionRepository
}); });
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
if (isset($data['config_from'])) { if (isset($data['config_from'])) {

View File

@ -114,7 +114,7 @@ class ServerRepository
// Run validator, throw catchable and displayable exception if it fails. // Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules. // Exception includes a JSON result of failed validation rules.
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
$user = Models\User::findOrFail($data['user_id']); $user = Models\User::findOrFail($data['user_id']);
@ -360,7 +360,7 @@ class ServerRepository
// Run validator, throw catchable and displayable exception if it fails. // Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules. // Exception includes a JSON result of failed validation rules.
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
DB::beginTransaction(); DB::beginTransaction();
@ -437,7 +437,7 @@ class ServerRepository
// Run validator, throw catchable and displayable exception if it fails. // Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules. // Exception includes a JSON result of failed validation rules.
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
DB::beginTransaction(); DB::beginTransaction();
@ -492,7 +492,7 @@ class ServerRepository
// Run validator, throw catchable and displayable exception if it fails. // Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules. // Exception includes a JSON result of failed validation rules.
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
DB::beginTransaction(); DB::beginTransaction();

View File

@ -48,7 +48,7 @@ class ServiceRepository
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
return DB::transaction(function () use ($data) { return DB::transaction(function () use ($data) {
@ -94,7 +94,7 @@ class ServiceRepository
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
return DB::transaction(function () use ($data, $service) { return DB::transaction(function () use ($data, $service) {

View File

@ -67,7 +67,7 @@ class UserRepository
// Run validator, throw catchable and displayable exception if it fails. // Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules. // Exception includes a JSON result of failed validation rules.
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
DB::beginTransaction(); DB::beginTransaction();
@ -141,7 +141,7 @@ class UserRepository
// Run validator, throw catchable and displayable exception if it fails. // Run validator, throw catchable and displayable exception if it fails.
// Exception includes a JSON result of failed validation rules. // Exception includes a JSON result of failed validation rules.
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
// The password and root_admin fields are not mass assignable. // The password and root_admin fields are not mass assignable.

View File

@ -63,7 +63,7 @@ class VariableRepository
}); });
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
if (isset($data['env_variable'])) { if (isset($data['env_variable'])) {
@ -137,7 +137,7 @@ class VariableRepository
}); });
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException(json_encode($validator->errors()));
} }
if (isset($data['env_variable'])) { if (isset($data['env_variable'])) {