Welcome Guest, Not a member yet? Register   Sign In
Custom Validation doesn't work?
#2

(This post was last modified: 12-07-2018, 06:50 AM by donpwinston.)

The way I did it:

Config/Validation.php
PHP Code:
/**
     * Stores the classes that contain the
     * rules that are available.
     *
     * @var array
     */
    
public $ruleSets = [
        \
CodeIgniter\Validation\Rules::class,
        \
CodeIgniter\Validation\FormatRules::class,
        \
CodeIgniter\Validation\FileRules::class,
        \
CodeIgniter\Validation\CreditCardRules::class,
        \
App\Validation\MyRules::class
    ]; 


Application/Validation/MyRules.php

PHP Code:
<?php namespace App\Validation;

class 
MyRules
{
    public function 
valid_login(string $emailstring $field, array $data): bool
    
{
        
$db = new \App\Libraries\NcrsEbnDb();
        
$hashed_password $db->getPassword(trim($email));
        if (
$hashed_password == '')
            return 
false;
        else
            return 
password_verify(trim($data[$field]), $hashed_password);
    }

    public function 
valid_password(string $passwordstring $field, array $data): bool
    
{
        
$db = new \App\Libraries\NcrsEbnDb();
        
$hashed_password $db->getPassword(trim($data[$field]));
        if (
$hashed_password == '')
            return 
false;
        else
            return 
password_verify(trim($password), $hashed_password);
    } 



..etc
Simpler is always better
Reply


Messages In This Thread
Custom Validation doesn't work? - by sibiniv - 12-06-2018, 11:34 PM
RE: Custom Validation doesn't work? - by donpwinston - 12-07-2018, 05:31 AM
RE: Custom Validation doesn't work? - by kilishan - 12-07-2018, 08:23 AM
RE: Custom Validation doesn't work? - by sibiniv - 12-09-2018, 07:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB