combine validation

This commit is contained in:
Dane Everitt 2017-03-12 18:31:56 -04:00
parent d67f65bb71
commit 66e94dd7c0
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -130,7 +130,9 @@ class OptionRepository
'config_from' => 'sometimes|required|numeric|exists:service_options,id', 'config_from' => 'sometimes|required|numeric|exists:service_options,id',
]); ]);
$validator->sometimes('config_startup', 'required_without:config_from|json', function ($input) use ($option) { $validator->sometimes([
'config_startup', 'config_logs', 'config_files',
], 'required_without:config_from|json', function ($input) use ($option) {
return ! (! $input->config_from && ! is_null($option->config_from)); return ! (! $input->config_from && ! is_null($option->config_from));
}); });
@ -138,14 +140,6 @@ class OptionRepository
return ! (! $input->config_from && ! is_null($option->config_from)); return ! (! $input->config_from && ! is_null($option->config_from));
}); });
$validator->sometimes('config_logs', 'required_without:config_from|json', function ($input) use ($option) {
return ! (! $input->config_from && ! is_null($option->config_from));
});
$validator->sometimes('config_files', 'required_without:config_from|json', function ($input) use ($option) {
return ! (! $input->config_from && ! is_null($option->config_from));
});
if ($validator->fails()) { if ($validator->fails()) {
throw new DisplayValidationException($validator->errors()); throw new DisplayValidationException($validator->errors());
} }