A set of useful form validation rules, focused on file uploading (and some more). English corrections and other languages are welcome.
Written by Joseba Juaniz (@Patroklo) and Jeroen van Meerendonk (@jeroen_bz). Original code written by devbro ([email protected]).
Codeigniter 3.x Php 5.2 or above
Just put copy the files into your server using the same folder structure. If you already have an english language file,
open it and add the content of /application/language/english/form_validation_lang.php
, and do the same with the other
languages.
Use them as the other rules.
file_required
Checks if the a required file is uploaded.file_size_max[size]
Returns FALSE if the file is bigger than the given size.file_size_min[size]
Returns FALSE if the file is smaller than the given size.file_allowed_type[type]
Tests the file extension for valid file types. You can put a group too (image, application, word_document, code, zip).file_disallowed_type[type]
Tests the file extension for no-valid file typesfile_image_maxdim[x,y]
Returns FALSE if the image is smaller than given dimension.file_image_mindim[x,y]
Returns FALSE if the image is bigger than given dimension.file_image_exactdim[x,y]
Returns FALSE if the image is not the given dimension.is_exactly[list]
Check if the field's value is in the list.is_not[list]
Check if the field's value is not permitted.valid_hour[type]
Check if the field's value is a valid hour. [24H or 12H]valid_date[date_format]
Check if the field's value has a valid format. If not provided with a format, it will use the standard value.valid_range_date[date_format]
Check if the field's value has a valid range of two date formats. If not provided with a format, it will use the standard value.valid_geopos[latitude;longitude]
Check if latitude and longitude parameters are valid.valid_multiple_geopos[json made of array of latitude;longitude]
Check if latitude and longitude parameters are valid.
- Added valid_geopos and valid_multiple_geopos
- Added PHP 5.2 compatibility. Bettered the mime loading from config directory
- Now the error field message shows all the error messages that it has and not only the first one.
- Where there is a file upload, now file_required and required force the user to upload a file.
- Added image icon mimes.
- Added valid_date method that checks if a field has a valid date format.
- Added valid_range_date method that checks if a field has a valid range of two dates.
- Changed
valid_hour
rule to accept 24 and 12 hour format - Changed
file_allowed_type
andfile_disallowed_type
to use Mime type when possible instead of extension file. - Added more spanish and english translations.
- Add
valid_hour
rule.
- Upgraded and working with CodeIgniter 2.1.
- Separated the error messages from the library and move them to
/application/language
- Added
is_exactly
andis_not
rules. - Added spanish translation.
- Fixed the issue: http://codeigniter.com/forums/viewthread/123816/P30/#629711 (by devbro)