Replies: 2 comments
-
What about use case 3: Allow urls without protocol?
Now it need some extra code like this:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
May be name it "uri_schema" or just "protocol"? Also i think it's worth to allow empty $parameters. Say, I have a protocol only field. Yes, a can use "in" rule, but starts_with exists too. P.S.: Do not forget to mention the difference with existing starts_with in PR. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Often a requirement for an url is, that it only matches a specific protocol.
Example:
At the moment, the "url" validation rule allows any IANA-registered protocol/scheme without limitation. The new proposed "url_protocols" rule still uses the IANA set, but allows to limit the allowed protocols. Example: 'url_protocols:https'
"url_protocols" is NOT a replacement for the "url" rule. It's an additional, more specific rule.
(Side node: The IANA-registered protocols/schemes are defined in the Laravel source code. See src/Illuminate/Validation/Concerns/ValidatesAttributes.php ->validateUrl() and listed here: https://en.wikipedia.org/wiki/List_of_URI_schemes)
Use case 1: Only urls with HTTPS or HTTP protocol allowed.
Use case 2: Only urls with SFTP protocol allowed.
Implementation idea
Error message
Documentation
src/Illuminate/Validation/Concerns/ValidatesAttributes.php
src/Illuminate/Validation/Concerns/ReplacesAttributes.php
resources/lang/en/validation.php
Beta Was this translation helpful? Give feedback.
All reactions