<?php
namespace App\Model\Table;

use Cake\ORM\Table;
use Cake\Validation\Validator;

/**
 * ReportFormatGenerationHistories Model

 * @method \App\Model\Entity\ReportFormatGenerationHistory get($primaryKey, $options = [])
 * @method \App\Model\Entity\ReportFormatGenerationHistory newEntity($data = null, array $options = [])
 * @method \App\Model\Entity\ReportFormatGenerationHistory[] newEntities(array $data, array $options = [])
 * @method \App\Model\Entity\ReportFormatGenerationHistory|false save(\Cake\Datasource\EntityInterface $entity, $options = [])
 * @method \App\Model\Entity\ReportFormatGenerationHistory saveOrFail(\Cake\Datasource\EntityInterface $entity, $options = [])
 * @method \App\Model\Entity\ReportFormatGenerationHistory patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
 * @method \App\Model\Entity\ReportFormatGenerationHistory[] patchEntities($entities, array $data, array $options = [])
 * @method \App\Model\Entity\ReportFormatGenerationHistory findOrCreate($search, callable $callback = null, $options = [])
 */
class ReportFormatGenerationHistoriesTable extends Table
{
    /**
     * Initialize method
     *
     * @param array $config The configuration for the Table.
     * @return void
     */
    public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setTable('report_format_generation_histories');
        $this->setPrimaryKey('id');

    }

    /**
     * Default validation rules.
     *
     * @param \Cake\Validation\Validator $validator Validator instance.
     * @return \Cake\Validation\Validator
     */
    public function validationDefault(Validator $validator)
    {
        $validator
            ->integer('id')
            ->allowEmptyString('id', null, 'create');

        $validator
            ->integer('report_format_id')
            ->requirePresence('report_format_id', 'create')
            ->notEmptyString('report_format_id');

        $validator
            ->scalar('name')
            ->maxLength('name', 100)
            ->requirePresence('name', 'create')
            ->notEmptyString('name');

        $validator
            ->scalar('receiver_emails')
            ->requirePresence('receiver_emails', 'create')
            ->notEmptyString('receiver_emails');

        $validator
            ->scalar('file_path')
            ->allowEmptyString('file_path');

        $validator
            ->dateTime('expiration_at')
            ->allowEmptyDateTime('expiration_at');

        $validator
            ->integer('status');

        $validator
            ->integer('created_by_id')
            ->allowEmptyString('created_by_id');

        $validator
            ->integer('updated_by_id')
            ->allowEmptyString('updated_by_id');

        $validator
            ->dateTime('created_at')
            ->allowEmptyDateTime('created_at');

        $validator
            ->dateTime('updated_at')
            ->allowEmptyDateTime('updated_at');

        return $validator;
    }
}
