timacdonald / rule-builder Goto Github PK
View Code? Open in Web Editor NEWFluent validation rule builder for Laravel.
Home Page: https://timacdonald.me/fluent-validation-rules-for-laravel/
License: MIT License
Fluent validation rule builder for Laravel.
Home Page: https://timacdonald.me/fluent-validation-rules-for-laravel/
License: MIT License
Allowing extended rules to have helpers would be nice. Probably implement a Illuminate\Support\Fluent
type extension interface.
The min
and max
helpers should skip applying the rule if the value is null
. Allows
Rule::string(null, 100)
Perhaps a strict option that throws an exception when duplicate rules are added and a non-strict option that just utilises the last declared rule.
This package looks really nice, but there's one thing I would change to make it much more efficient.
When you provide a string separated by pipes to the Laravel validator, it splits the string back into an array immediately. Therefore, I suggest that you just return the array instead of concatenating the rules back into a string. You already have the array and that's exactly how Laravel is going to use it, so why not?
In most of my projects until this point, I have specified my validation rules as arrays instead of strings in my code.
This is exactly what I was looking for. The laravel validation strings are hard to remember, hard to read, and take forever to write. This solves all those problems. Well done on this, mate.
Allow the hostname extension to be explicit i.e.
Rule::urlWithHostExtension('.com.au')
Do you think this should just be a macro on the \Illuminate\Validation\Rule
class instead of its own?
Allow default helpers values. With this a user could set the email
rule to have a default max:255
rule also applied.
Thus...
Rule::email(255)->get() === Rule::email()->get()
All helpers to pass 'default' and then get the Scheme builder default string length as max.
Rule::url('default')->get(),
Make sure you can add validation objects coming in LV5.5
Need to verify how far back the versions can go in the composer.json
There would be a testing term for the EloquentDummy class. Find it, use it.
would be nice to match the migration builder schema as much as possible. See of there are any additions that can be made to make this match more.
Worthwhile allowing Carbon to be used more closely with date rules, either carbon constants or carbon instances? after:date
for example.
Would love to be able to remove the call to get. Maybe array accessible, but maybe check through validator source to see if there are array
type hints specifically
Allow a global setting to auto-prepend urls with a schema.
I often have users submitting urls like www.github.com
which doesn't validate with the url
validation rule because it doesn't have a scheme.
Would be sweet to do in a service provider:
Rule::prependUrlScheme('http://');
or inline like
$rules = [
'website' =>Rule::required()->url(255)->prependScheme('http://')->get(),
];
Is there any mechanism in this to add custom validation rules. Or are there any plan on doing so.
Tests, test, tests!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.