I am working on an authorization system for Kohana. I do this only for education ...
This is what my controller looks like, which checks for submitted fields:
$validation =
Validation::factory( $_POST )
->rule( 'username', 'not_empty' )
->rule( 'username', 'max_length', array( ':value', 32 ) )
->rule( 'username', 'alpha_dash', array( ':value', true ) )
->rule( 'password', 'not_empty' )
->rule( 'password', 'min_length', array( ':value', 6 ) )
->rule( 'password', 'max_length', array( ':value', 255 ) )
->rule( 'passwordRepeatedly', 'not_empty' )
->rule( 'passwordRepeatedly', 'matches', array( ':validation', 'passwordRepeatedly', 'password' ) )
->rule( 'email', 'not_empty' )
->rule( 'email', 'email' );
I am looking for a way to display a different error message for each rule added. My goal is to pass it on (one or all (if occurs)) in order to view and display them there.
Pseudo Code:
errorFor( 'username', 'not_empty' ) => 'Username is required! Try again...';
How to determine a different error for each rule? I can not find anything clear to me in the documents ...
source
share