Answer the question
In order to leave comments, you need to log in
How to convert LIVR validation rules to php?
I decided to try the validation libraries on the LIVR validation syntax livr-spec.org
The point
is that the same rules should work both in the frontend and in the backend. I bribed the idea that once I set the rules in the syntax
{
name: 'required',
email: ['required', 'email'],
gender: { one_of: ['male', 'female'] },
phone: {max_length: 10},
password: ['required', {min_length: 10} ],
password2: { equal_to_field: 'password' }
}
$validator = new Validator\LIVR( [
'name' => 'required',
'email' => [ 'required', 'email'],
'gender' => [ 'one_of' => ['male', 'female'] ],
'phone' => [ 'max_length' => 10 ],
'password' => [ 'required', ['min_length' => 10] ],
'password2' => [ 'equal_to_field' => 'password' ]
] );
Answer the question
In order to leave comments, you need to log in
If anyone needs it in the future, then this is Json5.
You need to google the php library to work with json5.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question