Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
What's wrong with this validation object?
JeanAlesi
August 2015
$val = Validation::forge('my_validation');
$val->add('search_target', 'search_target')->add_rule('required');
$val->add('tmtrip_id', 'tmtrip_id')->add_rule('required|valid_string[numeric]');
The program says the last rule is invalid... But in the documentation (validation class), valid_string is mentioned as as a rule, and 'numeric' is mentioned as a array parameter for valid_string...
Am I using it the wrong way?
Harro
August 2015
Accepted Answer
You're using incorrect syntax.
As the example (
http://docs.fuelphp.com/classes/validation/validation.html#rules
) shows, there are two ways to define rules for a field:
using add_field(), in which you define all rules in a single string (the syntax you used), or
add_rule(), which is used to define a single rule
Since you're using the last one, it should be
$val->add('tmtrip_id', 'tmtrip_id')
->add_rule('required')
->add_tule('valid_string', array('numeric'));
JeanAlesi
August 2015
Thank you very much
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,088
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
260
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
August 2015
JeanAlesi
August 2015