Skip to content

Commit 66e94dd

Browse files
committed
combine validation
1 parent d67f65b commit 66e94dd

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

app/Repositories/OptionRepository.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,16 @@ public function update($id, array $data)
130130
'config_from' => 'sometimes|required|numeric|exists:service_options,id',
131131
]);
132132

133-
$validator->sometimes('config_startup', 'required_without:config_from|json', function ($input) use ($option) {
133+
$validator->sometimes([
134+
'config_startup', 'config_logs', 'config_files',
135+
], 'required_without:config_from|json', function ($input) use ($option) {
134136
return ! (! $input->config_from && ! is_null($option->config_from));
135137
});
136138

137139
$validator->sometimes('config_stop', 'required_without:config_from|string|max:255', function ($input) use ($option) {
138140
return ! (! $input->config_from && ! is_null($option->config_from));
139141
});
140142

141-
$validator->sometimes('config_logs', 'required_without:config_from|json', function ($input) use ($option) {
142-
return ! (! $input->config_from && ! is_null($option->config_from));
143-
});
144-
145-
$validator->sometimes('config_files', 'required_without:config_from|json', function ($input) use ($option) {
146-
return ! (! $input->config_from && ! is_null($option->config_from));
147-
});
148-
149143
if ($validator->fails()) {
150144
throw new DisplayValidationException($validator->errors());
151145
}

0 commit comments

Comments
 (0)