Welcome Guest, Not a member yet? Register   Sign In
Using class methods validation config
#1

Hi,

i set my rules in Config/Validation.php.
Is it possible to use a method in this class and use this method (to access other class variables) as a rule group?

PHP Code:
class Validation extends BaseConfig {
  public 
$field = []

  public 
method() {
    return 
something
  
}

}

$validation->getRuleGroup('field'// is working
$validation->getRuleGroup('method'// not found 
Reply
#2

(09-19-2022, 10:11 AM)groovebird Wrote: Is it possible to use a method in this class and use this method (to access other class variables) as a rule group?

No. methods are not properties.
Reply
#3

(09-21-2022, 03:00 AM)kenjis Wrote:
(09-19-2022, 10:11 AM)groovebird Wrote: Is it possible to use a method in this class and use this method (to access other class variables) as a rule group?

No. methods are not properties.

@kenjis i would use a configuration variable within the error message but in a property i have no access to the configuration. Is there a way to do that?
Reply
#4

PHP Code:
$config config('Validation');
$rules $config->method();
$validation->setRules($rules); 
Reply
#5

(09-21-2022, 03:24 PM)kenjis Wrote:
PHP Code:
$config config('Validation');
$rules $config->method();
$validation->setRules($rules); 

Ah this is cool. If i can't use the getRulesGroup-Method this is a good alternative.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB