<?php
defined( 'ABSPATH' ) or exit;   // show a blank page if try to access this file directly

require_once( EWZ_PLUGIN_DIR . "classes/validation/ewz-input.php");

/* Validation for the csv file upload form on Webforms page */
/* Processed by webforms.php                                */

class Ewz_CSV_Input extends Ewz_Input
{
    /**
     * @param mixed $form_data
     *
     * @return void
     */
     function __construct( $form_data ) {
         parent::__construct( $form_data );

        /*** rules('type') specifies the function called to validate, defined either here or in ewz-input.php */
        /*** rules('val') defines extra args to pass */
         $this->rules = array(

                  '_wp_http_referer'=> array( 'type' => 'to_string', 'req' => false, 'val' => '' ),
                  'ewzmode'         => array( 'type' => 'limited',   'req' => true,  'val' => ['csv','itmcsvdata','entrydata' ] ),
                  'ewznonce'        => array( 'type' => 'anonce',    'req' => true,  'val' => '' ),
                  'webform_id'      => array( 'type' => 'to_seq',    'req' => true,  'val' => ['len' => 10] ),
                  'itmcsv_btn'      => array( 'type' => 'noval',     'req' => false,  'val' => '' ),
                  'imgcsv_btn'      => array( 'type' => 'noval',     'req' => false,  'val' => '' ),
                  'entry_radio'     => array( 'type' => 'limited',   'req' => false,  'val' => [ 'check', 'upload'] ),
                  'openwebform'     => array( 'type' => 'to_seq',    'req' => false,  'val' => ['len' => 10] ),
                  'page'            => array( 'type' => 'fixed',     'req' => true,  'val' => 'entrywizard' )
                  );
        $this->validate();
     }

}