Create a new ValidationBase::class in the App/Classes directory.
Create a new 'ValidationBaseInterfacein the App/Interfaces directory and add any necessary interface methods which will be required by the ValidationBase::class.
This class will need to be extended by any other resource which will need validation for certain fields.
This class will have the following validation capabilities:
is array;
is int;
is numeric;
is string;
match : ( will match the provided regex );
not null;
uppercase letters;
lowercase letters;
The class will have the following method and will accept two parameters:
first parameter will be a string of rules which will apply in the order they were declared separated by |;
second parameter will be an array with the data on which these rules will be executed;
public function validate(string $rules, array $data):
will execute validation of rules on the given data;
if any rule fails will stack an array with errors for each field and specify what error occurred for the given data;
Description:
Create a new
ValidationBase::class
in theApp/Classes
directory.Create a new 'ValidationBaseInterface
in the App/Interfaces
directory and add any necessary interface methods which will be required by theValidationBase::class
.This class will need to be extended by any other resource which will need validation for certain fields.
This class will have the following validation capabilities:
The class will have the following method and will accept two parameters:
|
;public function validate(string $rules, array $data)
: