Skip to content
This repository has been archived by the owner on Sep 5, 2018. It is now read-only.

Create a new release? #1

Closed
royduin opened this issue Aug 2, 2017 · 7 comments
Closed

Create a new release? #1

royduin opened this issue Aug 2, 2017 · 7 comments

Comments

@royduin
Copy link

royduin commented Aug 2, 2017

Now I've to use composer require sebastiaanluca/laravel-validator:dev-develop to get it working.

@sebastiaanluca
Copy link
Owner

First of all, congrats, you're one of the 4 users using this package! :D

Secondly, what Laravel version are you using? I tried to use it in 5.5 yesterday, but noticed I didn't explicitly enable support for it yet. Was planning on doing so along the way, but might as well prioritize this.

Note that this is still a dev package. I'm looking into the new Laravel 5.5 validate method which returns the valid data straight away. Need to confirm it's still different from what this package does or if it needs to be deprecated from 5.5 onwards.

@royduin
Copy link
Author

royduin commented Aug 2, 2017

Haha, I found it at the comments on Laracasts, and it seems handy because I've disabled mass assignment with protected $guarded = []; on my model but I only want to get the validated fields. Came across this when using the confirmed validation rule where I've a email_confirmation field which resulted in a SQL errors because I don't have that column in the database and I'm using $request->all();. I could use $request->only([]); but that feels like duplication.

But... I'm using Laravel 5.4, with the current release version I'm getting an error about the array_expand() function which doesn't exist, so I've tried the version on develop which works great.

@sebastiaanluca
Copy link
Owner

Ha yeah, I'm using the same flow. Not using $guarded allows me to set whatever I want for a model internally, but user input should still be validated. Perfect place for that are form requests in a controller as that's the place a user request enters first.

I'll set up a test project later today to figure out what the problem is. I'll keep you posted.

@sebastiaanluca
Copy link
Owner

Pushed an intermediate v0.2.0 release so you can use this with the ~0.2.0 composer constraint (I'd advise against using ^0.2 as that will auto-update to 0.3 and could break things).

https://github.com/sebastiaanluca/laravel-validator/releases/tag/0.2.0

Problem was just that array_expand() like you mentioned. My "test" project had laravel-helpers installed, so it didn't throw a fit on my system. I'll do a proper v1 release someday, with tests!

@royduin
Copy link
Author

royduin commented Aug 2, 2017

Awesome! Thank you!

@royduin
Copy link
Author

royduin commented Aug 30, 2017

@sebastiaanluca, just an update, it looks like Laravel added it in Laravel 5.5, see: https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Http/FormRequest.php#L168:L178 and https://twitter.com/PendoNL/status/902935537417412609. I've not yet tested it, no idea if it also works with array field names but I'm going to try it tomorrow.

@sebastiaanluca
Copy link
Owner

sebastiaanluca commented Aug 30, 2017

I've been meaning to test Laravel 5.5's validate method since I saw the first tweets about it a few weeks/months ago. I've been working on a 5.5 project for a month now and can confirm both the controller's validate() as the form request's validated() method will return only input data that has a corresponding rule. I've updated the GitHub description accordingly a few days ago.

I haven't had the chance to test arrays yet, but from what I'm reading, $request->only() should handle wildcards. Although the result would be different from the input, but similar to how the rules are defined with wildcards and whatnot.

laravel/framework#17660 (implemented)
laravel/framework#19147 (wrong result)
laravel/ideas#578 (open issue)

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

No branches or pull requests

2 participants