PHP code example of ahmetbarut / validation

1. Go to this page and download the library: Download ahmetbarut/validation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ahmetbarut / validation example snippets


$validation = new ahmetbarut\Validation\Validate();

$validation->setFields($_POST)->setRules(
    [
        "id" => ["
 
namespace ahmetbarut\Validation\Validation\Rules;

use ahmetbarut\Validation\Validation\Rule;

class Number implements Rule
{

    public function check(string $attr, string $value): bool
    {
        return is_numeric($value);
    }

    public function message(): string
    {
        return "Sayısal olmalıdır!";
    }
}

use ahmetbarut\Validation\Validate;
use ahmetbarut\Validation\Validation\Rule;

 $value): bool
    {
        return is_numeric($value);
    }

    public function message(): string
    {
        return "Sayısal olmalıdır!";
    }
}

$validation = new ahmetbarut\Validation\Validate(["numara" => \Number::class]);

$validation->setFields($_POST)->setRules(
    [
        "id" => ["

$validation = new ahmetbarut\Validation\Validate(["numara" => \Number::class]);

$validation->setFields($_POST)->setRules(
    [
        "id" => ["

$validation = new ahmetbarut\Validation\Validate();

$validation->setFields($_POST)->setRules(
    [
        "id" => ["lFields();