Password::defaults() won't work in validator #59
-
Hello- I wanted to make a user sign-up wizard, and when I try to use the following array for rules:
I get an error in PHP storm: expression is not allowed as field default value. Also, I get the following error on the page: [Constant expression contains invalid operations]. (All these errors are pointing toward Password::defaults(). I cannot use any of the standard calls in Password, either, like min(), mixedCase(), etc... When I remove the rules array and use validator inside the submit function (see below) - everything works as expected.
I pored over the documentation but didn't see anything that might point at the issue. I am also somewhat sleep deprived at the moment, so there's that too. On the other hand, if this is an error with the package, I thought I should post something. In the meantime, is there any reason I shouldn't be using Laravel's Validator class instead of the rules array that ships with the package? Also - is this package safe enough to use for user registration, since it seems it's not using a form to submit the fields and there's no @csrf token involved? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
On the use of the If you're worried about security, you should read https://laravel-livewire.com/docs/2.x/security. This package is just a wrapper around Livewire so you can create wizards with it. |
Beta Was this translation helpful? Give feedback.
On the use of the
Password
facade inside a public property; that's not possible with PHP, so this is not an issue with the package. If you want to specify the rules globally, you should create arules()
method on your Livewire class, see:https://laravel-livewire.com/docs/2.x/input-validation
If you're worried about security, you should read https://laravel-livewire.com/docs/2.x/security. This package is just a wrapper around Livewire so you can create wizards with it.