Fix rule validation?

This commit is contained in:
notCharles 2024-05-12 00:55:44 -04:00
parent c5b441e54a
commit 615b70f9a2
2 changed files with 4 additions and 4 deletions

View File

@ -252,13 +252,13 @@ class EditServer extends EditRecord
->schema([ ->schema([
Forms\Components\TextInput::make('variable_value') Forms\Components\TextInput::make('variable_value')
->rules([ ->rules([
fn (ServerVariable $variable): Closure => function (string $attribute, $value, Closure $fail) use ($variable) { fn (Forms\Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
$validator = Validator::make(['validatorkey' => $value], [ $validator = Validator::make(['validatorkey' => $value], [
'validatorkey' => $variable->variable->rules, 'validatorkey' => $get('rules'),
]); ]);
if ($validator->fails()) { if ($validator->fails()) {
$message = str($validator->errors()->first())->replace('validatorkey', $variable->variable->name); $message = str($validator->errors()->first())->replace('validatorkey', $get('name'));
$fail($message); $fail($message);
} }

View File

@ -1,5 +1,5 @@
<!doctype html> <!doctype html>
<html lang="en" data-theme="{{ config('scramble.theme', 'dark') }}"> <html lang="en" data-theme="dark">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">