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

Cleaner API #252

Open
dereuromark opened this issue Jan 5, 2024 · 1 comment
Open

Cleaner API #252

dereuromark opened this issue Jan 5, 2024 · 1 comment

Comments

@dereuromark
Copy link
Member

As shown in https://sandbox.dereuromark.de/sandbox/localized

There are several methods that are either kind of duplicates with a different name or contain underscore instead of camelBacked.
We should clean up the API here, deprecate one in favor of the correct spelling if possible.

All methods that shouldnt be visible, should be marked protected.

@dereuromark
Copy link
Member Author

dereuromark commented May 7, 2024

Also:

Referer: https://sandbox.dereuromark.de/sandbox/localized/basic?code=JP&method=hiragana
[TypeError] Cake\Localized\Validation\JpValidation::hiragana(): Argument #2 ($allowSpace) must be of type bool, array given, called in /var/www/dereuromark/sandbox5/vendor/cakephp/cakephp/src/Validation/ValidationRule.php on line 147 in /var/www/dereuromark/sandbox5/vendor/cakephp/localized/src/Validation/JpValidation.php on line 103
Stack Trace:
- /var/www/dereuromark/sandbox5/vendor/cakephp/cakephp/src/Validation/ValidationRule.php:147
- /var/www/dereuromark/sandbox5/vendor/cakephp/cakephp/src/Validation/Validator.php:3167
- /var/www/dereuromark/sandbox5/vendor/cakephp/cakephp/src/Validation/Validator.php:261
- /var/www/dereuromark/sandbox5/vendor/cakephp/cakephp/src/ORM/Marshaller.php:266
- /var/www/dereuromark/sandbox5/vendor/cakephp/cakephp/src/ORM/Marshaller.php:564
- /var/www/dereuromark/sandbox5/vendor/cakephp/cakephp/src/ORM/Table.php:3047
- /var/www/dereuromark/sandbox5/plugins/Sandbox/src/Controller/LocalizedController.php:72

hiragana() and katakana() have a 2nd option that is typed as bool which makes them impossible to get used with normal cake validation process of

$validator = $table->getValidator();
$class = 'Cake\\Localized\\Validation\\' . ucfirst(strtolower($code)) . 'Validation';
$validator->setProvider($code, $class);
$validator->add('value', 'localizedValidation', [
    'rule' => $method,
    'provider' => $code,
]);

We should make those an array or extract the bool value here before passing only that one on instead of the context as full array.
The latter is probably only doable with some custom callable or sth, as currently, this is not reachable with documented approach of adding localized validation rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant