PHP Classes

File: example/string.php

Recommend this page to a friend!
  Classes of Boss Ibrahim Mussa   Wepesi Validation   example/string.php   Download  
File: example/string.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Wepesi Validation
Validate a set of values using rule classes
Author: By
Last change:
Date: 1 year ago
Size: 1,044 bytes
 

Contents

Class file image Download
<?php
/*
 * Copyright (c) 2022. Wepesi validation.
 * @author Boss Ibrahim Mussa
 */
/**
 * Validate string
 */

use Wepesi\App\Schema;
use
Wepesi\App\Validate;

$schema = new Schema();
$validate = new Validate();
$source = [
   
'name' => 'ibrahim',
   
'country' => "",
   
'password' => '1234567',
   
'new_password' => 123456,
   
'email' => 'infos@wepesi.com',
   
'link' => 'https://github.com/bim-g/wepesi_validation/'
];
$rules = [
   
"name" => $schema->string()->email()->min(35)->max(50)->required()->generate(),
   
"country" => $schema->string()->min(3)->max(40)->required()->generate(),
   
"password" => $schema->string()->min(3)->max(40)->generate(),
   
"new_password" => $schema->string()->min(3)->max(40)->match("password")->generate(),
   
"email" => $schema->string()->min(3)->max(40)->email()->generate(),
   
"link" => $schema->string()->min(3)->max(40)->url()->generate(),
];
$validate->check($source, $rules);
//// check if the validation passed or not
var_dump($validate->passed());
var_dump($validate->errors());