Skip to content
This repository

form_validation lang 'valid_url', but no method #1966

GDmac opened this Issue · 8 comments

2 participants

GDmac Andrey Andreev

While trying to test issue #1850 i saw that the reporter uses
a valid_url rule in the form validation set_rules

There is no method or function named valid_url() anywhere, so the rule will actually never validate to TRUE.
However, there is a language line for valid_url here:

shouldn't either that line be removed to prevent confusion, or a method be added to actually test for valid_url() ?


Additionally, if a rule can't be found, the form validation class logs a message,
but at the debug level. Shouldn't that be raised to the error level?

Andrey Andreev

Well, that's strange ... there was never a valid_url rule, but that language line has existed during all the time since CI 1.0.


Did some diggin. It looks like some apps use the lang line independently from form_validation.
for instance when a non-existant id is requested /app/products/show/233 it just shows lang('invalid_url')

maybe add a method to form_validation then?

  • filter_var($str, FILTER_VALIDATE_URL)

edit: FILTER_VALIDATE_URL is maybe not appropriate.

Andrey Andreev

invalid_url has nothing to do with this.

Otherwise, I guess we can add a valid_url() method and I do understand your concerns over FILTER_VALIDATE_URL, but I still think it should be used, even if in combination with some additional check.


As mentioned above, i'ld like to suggest raising the error level when using rules with non-existing functions.

Andrey Andreev

You no longer want to implement and submit a PR with the rule method? You could include the error-level change in there.


yes, will do. Need some time. seems there are some issues with filter_var in php 5.2.13

Andrey Andreev

Implemented, see the above commit.

Kyra Zimmer nonchip referenced this issue from a commit in nonchip/CodeIgniter
Andrey Andreev narfbg Add 'valid_url' rule to Form Validation (issue #1966) 296313a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.