<?php
// src/Model/Table/ArticlesTable.php
namespace App\Model\Table;

use Cake\ORM\Table;
// the Text class
use Cake\Utility\Text;
use Cake\Validation\Validator;
use Josegonzalez\Upload\File\Path\ProcessorInterface;
// Add the following method.

class MemberTable extends Table
{
    public function initialize(array $config)
    {
        $this->setTable('member');
        $this->setDisplayField('mem_name');
        $this->setPrimaryKey('mem_no');
        $this->addBehavior('Josegonzalez/Upload.Upload', [
            'mem_image' => []
        ]);
    }
    public function validationDefault(Validator $validator)
    {
        $validator
            ->notEmpty('mem_no')
            ->notEmpty('mem_name')
            ->notEmpty('division')
        ->notEmpty('section')
        ->allowEmpty('pincode')
             ->add('pincode', [
        'minLength' => [
            'rule' => ['minLength', 6],
   
            'message' => 'Invalid Pincode.'
        ],
        'maxLength' => [
            'rule' => ['maxLength', 6],
            'message' => 'Invalid Pincode.'
        ]
    ])
     ->allowEmpty('phone')
             ->add('phone', [
        'minLength' => [
            'rule' => ['minLength', 10],
   
            'message' => 'Invalid Mobile Number.'
        ],
        'maxLength' => [
            'rule' => ['maxLength', 10],
            'message' => 'Invalid Mobile Number.'
        ]
    ]);
        return $validator;
    }
}
?>