admin/controllers/Customer.php
protected function formValidation()
    {
        $aRules = [
            'first_name'               => 'max_length[255]',
            'last_name'                => 'max_length[255]',
            'organisation'             => 'max_length[255]',
            'email'                    => 'max_length[255]|valid_email|required',
            'billing_email'            => 'max_length[255]|valid_email',
            'telephone'                => 'max_length[25]',
            'vat_number'               => 'max_length[25]',
            'billing_address_line_1'   => 'max_length[255]',
            'billing_address_line_2'   => 'max_length[255]',
            'billing_address_town'     => 'max_length[255]',
            'billing_address_county'   => 'max_length[255]',
            'billing_address_postcode' => 'max_length[255]',
            'billing_address_country'  => 'max_length[255]',
        ];

        $oFormValidation = Factory::service('FormValidation');
        foreach ($aRules as $sKey => $sRule) {
            $oFormValidation->set_rules($sKey, '', $sRule);
        }

        $oFormValidation->set_message('required', lang('fv_required'));
        $oFormValidation->set_message('max_length', lang('fv_max_length'));
        $oFormValidation->set_message('valid_email', lang('fv_valid_email'));

        if (!$oFormValidation->run()) {
            throw new NailsException(lang('fv_there_were_errors'), 1);
        }

        //  First/Last name is required if no organisation is provided
        $oInput        = Factory::service('Input');
        $sOrganisation = $oInput->post('organisation');
        $sFirstName    = $oInput->post('first_name');
        $sLastName     = $oInput->post('last_name');
        if (empty($sOrganisation) && (empty($sFirstName) || empty($sLastName))) {
            throw new NailsException('First name and surname are required if not providing an organisation.', 1);
        }
    }
protected function formValidation()
    {
        $aRules = [
            'first_name'               => 'max_length[255]',
            'last_name'                => 'max_length[255]',
            'organisation'             => 'max_length[255]',
            'email'                    => 'max_length[255]|valid_email|required',
            'billing_email'            => 'max_length[255]|valid_email',
            'telephone'                => 'max_length[25]',
            'vat_number'               => 'max_length[25]',
            'billing_address_line_1'   => 'max_length[255]',
            'billing_address_line_2'   => 'max_length[255]',
            'billing_address_town'     => 'max_length[255]',
            'billing_address_county'   => 'max_length[255]',
            'billing_address_postcode' => 'max_length[255]',
            'billing_address_country'  => 'max_length[255]',
        ];

        $oFormValidation = Factory::service('FormValidation');
        foreach ($aRules as $sKey => $sRule) {
            $oFormValidation->set_rules($sKey, '', $sRule);
        }

        $oFormValidation->set_message('required', lang('fv_required'));
        $oFormValidation->set_message('max_length', lang('fv_max_length'));
        $oFormValidation->set_message('valid_email', lang('fv_valid_email'));

        if (!$oFormValidation->run()) {
            throw new NailsException(lang('fv_there_were_errors'), 1);
        }

        //  First/Last name is required if no organisation is provided
        $oInput        = Factory::service('Input');
        $sOrganisation = $oInput->post('organisation');
        $sFirstName    = $oInput->post('first_name');
        $sLastName     = $oInput->post('last_name');
        if (empty($sOrganisation) && (empty($sFirstName) || empty($sLastName))) {
            throw new NailsException('First name and surname are required if not providing an organisation.', 1);
        }
    }
protected function formValidation ( ) { $ aRules = [ 'first_name' => 'max_length[255]' , 'last_name' => 'max_length[255]' , 'organisation' => 'max_length[255]' , 'email' => 'max_length[255]|valid_email|required' , 'billing_email' => 'max_length[255]|valid_email' , 'telephone' => 'max_length[25]' , 'vat_number' => 'max_length[25]' , 'billing_address_line_1' => 'max_length[255]' , 'billing_address_line_2' => 'max_length[255]' , 'billing_address_town' => 'max_length[255]' , 'billing_address_county' => 'max_length[255]' , 'billing_address_postcode' => 'max_length[255]' , 'billing_address_country' => 'max_length[255]' , ] ; $ oFormValidation = Factory :: service ( 'FormValidation' ) ; foreach ( $ aRules as $ sKey => $ sRule ) { $ oFormValidation -> set_rules ( $ sKey , '' , $ sRule ) ; } $ oFormValidation -> set_message ( 'required' , lang ( 'fv_required' ) ) ; $ oFormValidation -> set_message ( 'max_length' , lang ( 'fv_max_length' ) ) ; $ oFormValidation -> set_message ( 'valid_email' , lang ( 'fv_valid_email' ) ) ; if ( ! $ oFormValidation -> run ( ) ) { throw new NailsException ( lang ( 'fv_there_were_errors' ) , 1 ) ; } //  First/Last name is required if no organisation is provided $ oInput = Factory :: service ( 'Input' ) ; $ sOrganisation = $ oInput -> post ( 'organisation' ) ; $ sFirstName = $ oInput -> post ( 'first_name' ) ; $ sLastName = $ oInput -> post ( 'last_name' ) ; if ( empty ( $ sOrganisation ) && ( empty ( $ sFirstName ) || empty ( $ sLastName ) ) ) { throw new NailsException ( 'First name and surname are required if not providing an organisation.' , 1 ) ; } }
Runs form validation
@return void
Runs form validation