Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization order #141

Merged
merged 2 commits into from
Jun 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

return [
'enum' => 'The value you have provided is not a valid enum instance.',
'enum_value' => 'The value you have entered is invalid.',
'enum_key' => 'The key you have entered is invalid.',
'enum' => __('The value you have provided is not a valid enum instance.'),
'enum_value' => __('The value you have entered is invalid.'),
'enum_key' => __('The key you have entered is invalid.'),
];
6 changes: 3 additions & 3 deletions src/EnumServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private function bootValidators()
$enum = $parameters[0] ?? null;

return (new EnumKey($enum))->passes($attribute, $value);
}, __('laravelEnum::messages.enum_key'));
});

$this->app['validator']->extend('enum_value', function ($attribute, $value, $parameters, $validator) {
$enum = $parameters[0] ?? null;
Expand All @@ -68,13 +68,13 @@ private function bootValidators()
$strict = !! json_decode(strtolower($strict));

return (new EnumValue($enum, $strict))->passes($attribute, $value);
}, __('laravelEnum::messages.enum_value'));
});

$this->app['validator']->extend('enum', function ($attribute, $value, $parameters, $validator) {
$enum = $parameters[0] ?? null;

return (new Enum($enum))->passes($attribute, $value);
}, __('laravelEnum::messages.enum'));
});
}

/**
Expand Down