Conversie codeigniter 4
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: imac-3
|
||||
* Date: 26/06/16
|
||||
* Time: 21:17
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/Validation.php' );
|
||||
|
||||
use App\Libraries\Validation\Validation;
|
||||
|
||||
class BaseValidation {
|
||||
|
||||
protected $validationField;
|
||||
protected $key;
|
||||
protected $fieldValue;
|
||||
protected $errorMessages = [];
|
||||
protected $validation;
|
||||
protected $fieldname;
|
||||
protected $validationResult;
|
||||
protected $request;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->request = \Config\Services::request();
|
||||
$this->validateInput();
|
||||
}
|
||||
|
||||
public function getValidationResult()
|
||||
{
|
||||
return $this->validationResult;
|
||||
}
|
||||
|
||||
public function validateInput()
|
||||
{
|
||||
$this->loopFields();
|
||||
}
|
||||
|
||||
public function getErrorMessages()
|
||||
{
|
||||
return $this->errorMessages;
|
||||
}
|
||||
|
||||
private function loopFields()
|
||||
{
|
||||
foreach ( $this->validationFields as $this->key => $this->validationField )
|
||||
{
|
||||
$this->validation = new Validation();
|
||||
|
||||
$this->setInputfield();
|
||||
|
||||
$this->validateFieldvalue();
|
||||
|
||||
$this->setFieldname();
|
||||
|
||||
$this->setValidationResult();
|
||||
|
||||
$this->setErrorMesagges();
|
||||
}
|
||||
}
|
||||
|
||||
private function setInputfield()
|
||||
{
|
||||
$this->fieldValue = $this->request->getPost($this->key);
|
||||
}
|
||||
|
||||
private function validateFieldvalue()
|
||||
{
|
||||
$this->validation->validate( $this->fieldValue, $this->validationField );
|
||||
}
|
||||
|
||||
private function setFieldname()
|
||||
{
|
||||
$this->fieldname = $this->validationField['fieldname'];
|
||||
}
|
||||
|
||||
private function setErrorMesagges()
|
||||
{
|
||||
$this->errorMessages[ $this->fieldname ] = $this->validation->getErrorMessages();
|
||||
}
|
||||
|
||||
private function setValidationResult()
|
||||
{
|
||||
if( $this->validationResult === FALSE ) return;
|
||||
|
||||
$this->validationResult = $this->validation->getValidationResult();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class CustomerValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'name' => [
|
||||
'validations' => 'required|alphaNumericSpaces',
|
||||
'fieldname' => 'name'
|
||||
],
|
||||
'email' => [
|
||||
'validations' => 'email',
|
||||
'fieldname' => 'email'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class EmployeeTargetValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'user_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'gebruiker'
|
||||
],
|
||||
'startmonth' => [
|
||||
'validations' => 'integer',
|
||||
'fieldname' => 'startmaand'
|
||||
],
|
||||
'startyear' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'startjaar'
|
||||
],
|
||||
'target' =>[
|
||||
'validations' => 'integer',
|
||||
'fieldname' => 'uren target'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class ExternalValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'contactperson' => [
|
||||
'validations' => 'required|alphaNumericSpaces',
|
||||
'fieldname' => 'contact'
|
||||
],
|
||||
'email' => [
|
||||
'validations' => 'email',
|
||||
'fieldname' => 'email'
|
||||
],
|
||||
'rate' => [
|
||||
'validations' => 'numeric',
|
||||
'fieldname' => 'tarief'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class ForecastValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'project_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'project'
|
||||
],
|
||||
'year' => [
|
||||
'validations' => 'integer',
|
||||
'fieldname' => 'jaar'
|
||||
],
|
||||
'month_id' => [
|
||||
'validations' => 'integer',
|
||||
'fieldname' => 'maand'
|
||||
],
|
||||
'forecastamount' => [
|
||||
'validations' => 'number',
|
||||
'fieldname' => 'bedrag'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class InvoiceValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'project_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'project'
|
||||
],
|
||||
'invoicedate' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'factuurdatum'
|
||||
],
|
||||
'forecastdate' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'prognosedatum'
|
||||
],
|
||||
'invoiceamount' => [
|
||||
'validations' => 'number',
|
||||
'fieldname' => 'factuurbedrag'
|
||||
],
|
||||
'forecastamount' => [
|
||||
'validations' => 'number',
|
||||
'fieldname' => 'prognosebedrag'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: imac-3
|
||||
* Date: 26/06/16
|
||||
* Time: 21:13
|
||||
*/
|
||||
|
||||
class LoginValidation extends BaseValidation {
|
||||
|
||||
protected $validationFields = [
|
||||
'username' => [
|
||||
'validations' => 'required|alphaNumericSpaces',
|
||||
'fieldname' => 'gebruikersnaam'
|
||||
],
|
||||
'password' => [
|
||||
'validations' => 'required',
|
||||
'fieldname' => 'wachtwoord'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class OfferValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'customer_id' => [
|
||||
'validations' => 'required|numeric',
|
||||
'fieldname' => 'klant'
|
||||
],
|
||||
'startdate' => [
|
||||
'validations' => 'required|date',
|
||||
'fieldname' => 'offertedatum'
|
||||
],
|
||||
'acceptdate' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'acceptatiedatum'
|
||||
],
|
||||
'rejectdate' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'afwijsdatum'
|
||||
],
|
||||
'acceptance_chance' => [
|
||||
'validations' => 'numeric',
|
||||
'fieldname' => 'afwijsdatum|minvalue-0|maxvalue-100'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software
|
||||
* User: Theo Weijmer
|
||||
* Date: 26/06/16
|
||||
* Time: 20:39
|
||||
*/
|
||||
|
||||
class OrganisationValidation extends BaseValidation {
|
||||
|
||||
protected $validationFields = [
|
||||
'brin' => [
|
||||
'validations' => 'required|alphaNumeric',
|
||||
'fieldname' => 'brinnummer'
|
||||
],
|
||||
'naam' => [
|
||||
'validations' => 'required',
|
||||
'fieldname' => 'Organisatienaam'
|
||||
],
|
||||
'naamkort' => [
|
||||
'validations' => 'required',
|
||||
'fieldname' => 'Organisatienaam (kort)'
|
||||
],
|
||||
'vestiging' => [
|
||||
'validations' => 'required|alphaNumeric|unique',
|
||||
'fieldname' => 'vestigingsnummer',
|
||||
'model' => 'organisations_model',
|
||||
'field' => 'vestiging'
|
||||
],
|
||||
'email' => [
|
||||
'validations' => 'email',
|
||||
'fieldname' => 'email'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: imac-3
|
||||
* Date: 26/06/16
|
||||
* Time: 21:13
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class PasswordRequestValidation extends BaseValidation {
|
||||
|
||||
protected $validationFields = [
|
||||
'username' => [
|
||||
'validations' => 'required|alphaNumericSpaces',
|
||||
'fieldname' => 'gebruikersnaam'
|
||||
],
|
||||
'email' => [
|
||||
'validations' => 'required|email',
|
||||
'fieldname' => 'email'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class PaymentValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'invoice_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'factuur'
|
||||
],
|
||||
'paymentdate' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'betaaldatum'
|
||||
],
|
||||
'paymentamount' => [
|
||||
'validations' => 'number',
|
||||
'fieldname' => 'bedrag'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class ProjectValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'customer_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'klant'
|
||||
],
|
||||
'startdate' => [
|
||||
'validations' => 'required|date',
|
||||
'fieldname' => 'start project'
|
||||
],
|
||||
'enddate' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'eind project'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class ProjectcostValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'project_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'project'
|
||||
],
|
||||
'external_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'externe'
|
||||
],
|
||||
'date' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'datum'
|
||||
],
|
||||
'costs' => [
|
||||
'validations' => 'number',
|
||||
'fieldname' => 'kosten'
|
||||
],
|
||||
'payed' => [
|
||||
'validations' => 'number',
|
||||
'fieldname' => 'betaald'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class ProjectemployeeValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'user_id' => [
|
||||
'validations' => 'integer',
|
||||
'fieldname' => 'klant'
|
||||
],
|
||||
'startdate' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'start project'
|
||||
],
|
||||
'enddate' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'eind project'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->handleSpecificValidations();
|
||||
}
|
||||
|
||||
protected function handleSpecificValidations()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class ProjecthourValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'projectemployee_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'projectmedewerker'
|
||||
],
|
||||
'hourdate' => [
|
||||
'validations' => 'date',
|
||||
'fieldname' => 'datum'
|
||||
],
|
||||
'hours' => [
|
||||
'validations' => 'number',
|
||||
'fieldname' => 'uren'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class ReservationValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'project_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'project'
|
||||
],
|
||||
'external_id' =>[
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'onderaannemer'
|
||||
],
|
||||
'reservationamount' => [
|
||||
'validations' => 'number',
|
||||
'fieldname' => 'bedrag'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/07/16
|
||||
* Time: 13:35
|
||||
*/
|
||||
|
||||
require_once( APPPATH . 'Libraries/Validation/InputValidations/BaseValidation.php' );
|
||||
|
||||
class UserValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'firstname' => [
|
||||
'validations' => 'required|alphaNumericSpaces',
|
||||
'fieldname' => 'firstname'
|
||||
],
|
||||
'lastname' => [
|
||||
'validations' => 'required|alphaNumericSpaces',
|
||||
'fieldname' => 'lastname'
|
||||
],
|
||||
'email' => [
|
||||
'validations' => 'required|email|unique',
|
||||
'fieldname' => 'email',
|
||||
'model' => 'User_model',
|
||||
'field' => 'email'
|
||||
],
|
||||
'username' => [
|
||||
'validations' => 'required|alphanumeric|minlength-4|unique',
|
||||
'fieldname' => 'username',
|
||||
'model' => 'User_model',
|
||||
'field' => 'username'
|
||||
],
|
||||
'hourlyrate' =>[
|
||||
'validations' => 'decimal',
|
||||
'fieldname' => 'uurtarief'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
<?php
|
||||
|
||||
namespace App\Libraries\Validation;
|
||||
|
||||
use CodeIgniter\HTTP\IncomingRequest;
|
||||
|
||||
/**
|
||||
* Custom Validation Library
|
||||
* Migrated from CodeIgniter 3 to CodeIgniter 4
|
||||
*/
|
||||
class Validation
|
||||
{
|
||||
private $fieldValue;
|
||||
private $validations;
|
||||
private $validation;
|
||||
private $validationResult;
|
||||
private array $errorMessages = [];
|
||||
private $validationField;
|
||||
protected IncomingRequest $request;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->request = \Config\Services::request();
|
||||
}
|
||||
|
||||
public function validate($fieldValue, $validationField = false): void
|
||||
{
|
||||
$this->setValidationField($validationField);
|
||||
$this->setFieldValue($fieldValue);
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
public function setValidationField($validationfield): void
|
||||
{
|
||||
$this->validationField = $validationfield;
|
||||
}
|
||||
|
||||
public function getErrorMessages(): array
|
||||
{
|
||||
return $this->errorMessages;
|
||||
}
|
||||
|
||||
public function getValidationResult(): bool
|
||||
{
|
||||
return $this->validationResult;
|
||||
}
|
||||
|
||||
private function handle(): void
|
||||
{
|
||||
$this->setValidations();
|
||||
$this->checkValidations();
|
||||
$this->setValidationResult();
|
||||
}
|
||||
|
||||
private function setValidations(): void
|
||||
{
|
||||
$this->validations = explode('|', $this->validationField['validations']);
|
||||
}
|
||||
|
||||
private function setFieldValue($fieldValue): void
|
||||
{
|
||||
$this->fieldValue = $fieldValue;
|
||||
}
|
||||
|
||||
private function setValidationResult(): void
|
||||
{
|
||||
if (count($this->errorMessages) == 0) {
|
||||
$this->validationResult = true;
|
||||
return;
|
||||
}
|
||||
|
||||
$this->validationResult = false;
|
||||
}
|
||||
|
||||
private function checkValidations(): void
|
||||
{
|
||||
foreach ($this->validations as $this->validation) {
|
||||
if ($this->validation == 'required') $this->checkRequired();
|
||||
if ($this->validation == 'alpha') $this->checkAlfa();
|
||||
if ($this->validation == 'alphaNumeric') $this->checkAlfanumeric();
|
||||
if ($this->validation == 'alphaNumericSpaces') $this->checkAlphaNumericSpaces();
|
||||
if ($this->validation == 'alphaDash') $this->checkAlphaDash();
|
||||
if ($this->validation == 'numeric') $this->checkNumeric();
|
||||
if ($this->validation == 'integer') $this->checkInteger();
|
||||
if ($this->validation == 'decimal') $this->checkDecimal();
|
||||
if ($this->validation == 'email') $this->checkEmail();
|
||||
if ($this->validation == 'unique') $this->checkUnique();
|
||||
if ($this->validation == 'date') $this->checkDate();
|
||||
if (substr($this->validation, 0, 9) == 'minlength') $this->checkMinlength();
|
||||
if (substr($this->validation, 0, 9) == 'maxlength') $this->checkMaxlength();
|
||||
if (substr($this->validation, 0, 8) == 'minvalue') $this->checkMinvalue();
|
||||
if (substr($this->validation, 0, 8) == 'maxvalue') $this->checkMaxvalue();
|
||||
}
|
||||
}
|
||||
|
||||
public function checkRequired(): void
|
||||
{
|
||||
if (!$this->fieldValue || empty($this->fieldValue) || strlen($this->fieldValue) == 0)
|
||||
$this->errorMessages[] = 'veld is verplicht';
|
||||
}
|
||||
|
||||
public function checkAlfa(): void
|
||||
{
|
||||
$value = ctype_alpha($this->fieldValue);
|
||||
if (!$value) $this->errorMessages[] = 'alleen letters toegestaan';
|
||||
}
|
||||
|
||||
public function checkAlfaNumeric(): bool
|
||||
{
|
||||
$value = ctype_alnum((string)$this->fieldValue);
|
||||
if (!$value) $this->errorMessages[] = 'alleen letters en cijfers toegestaan';
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function checkAlphaNumericSpaces(): void
|
||||
{
|
||||
$value = (bool)preg_match('/^[A-Z0-9 ]+$/i', $this->fieldValue);
|
||||
if (!$value) $this->errorMessages[] = 'alleen letters, cijfers en spaties toegestaan';
|
||||
}
|
||||
|
||||
public function checkAlphaDash(): void
|
||||
{
|
||||
$value = (bool)preg_match('/^[a-z0-9_-]+$/i', $this->fieldValue);
|
||||
if (!$value) $this->errorMessages[] = 'alleen letters, cijfers en streepjes toegestaan';
|
||||
}
|
||||
|
||||
public function checkNumeric(): void
|
||||
{
|
||||
$value = (bool)preg_match('/^[\-+]?[0-9]*\.?[0-9]+$/', $this->fieldValue);
|
||||
if (!$value) $this->errorMessages[] = 'alleen getallen toegestaan';
|
||||
}
|
||||
|
||||
public function checkInteger(): void
|
||||
{
|
||||
$value = (bool)preg_match('/^[\-+]?[0-9]+$/', $this->fieldValue);
|
||||
if (!$value) $this->errorMessages[] = 'alleen gehele getallen toegestaan';
|
||||
}
|
||||
|
||||
public function checkDecimal(): void
|
||||
{
|
||||
$value = is_numeric($this->fieldValue);
|
||||
if (!$value) $this->errorMessages[] = 'alleen getallen toegestaan';
|
||||
}
|
||||
|
||||
public function checkEmail(): void
|
||||
{
|
||||
if (!$this->fieldValue || empty($this->fieldValue) || strlen($this->fieldValue) == 0) return;
|
||||
|
||||
$value = (bool)filter_var($this->fieldValue, FILTER_VALIDATE_EMAIL);
|
||||
if (!$value) $this->errorMessages[] = 'ongeldig emailadres';
|
||||
}
|
||||
|
||||
public function checkUnique(): void
|
||||
{
|
||||
$recordID = $this->request->getPost('id');
|
||||
$model = $this->validationField['model'];
|
||||
$field = $this->validationField['field'];
|
||||
|
||||
// For Eloquent models, we can call the static method directly
|
||||
$value = $model::checkUnique($recordID, $field, $this->fieldValue);
|
||||
|
||||
if (!$value) $this->errorMessages[] = 'invoer moet uniek zijn';
|
||||
}
|
||||
|
||||
public function checkDate(): void
|
||||
{
|
||||
if (empty($this->fieldValue)) return;
|
||||
|
||||
$dateParts = explode('-', $this->fieldValue);
|
||||
|
||||
if (count($dateParts) != 3) $dateParts = explode('/', $this->fieldValue);
|
||||
|
||||
if (count($dateParts) != 3) {
|
||||
$this->errorMessages[] = 'invoer is geen datum';
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkdate((int)$dateParts[1], (int)$dateParts[0], (int)$dateParts[2]))
|
||||
$this->errorMessages[] = 'invoer is geen datum';
|
||||
}
|
||||
|
||||
private function checkMinlength(): void
|
||||
{
|
||||
$length = explode('-', $this->validation);
|
||||
if (strlen($this->fieldValue) < (int)$length[1])
|
||||
$this->errorMessages[] = 'moet minimaal uit ' . $length[1] . ' karakters bestaan';
|
||||
}
|
||||
|
||||
private function checkMaxlength(): void
|
||||
{
|
||||
$length = explode('-', $this->validation);
|
||||
if (strlen($this->fieldValue) > (int)$length[1])
|
||||
$this->errorMessages[] = 'mag maximaal uit ' . $length[1] . ' karakters bestaan';
|
||||
}
|
||||
|
||||
private function checkMinValue(): void
|
||||
{
|
||||
$value = explode('-', $this->validation);
|
||||
if ($this->fieldValue < (float)$value[1])
|
||||
$this->errorMessages[] = 'moet minimaal ' . $value[1] . ' zijn';
|
||||
}
|
||||
|
||||
private function checkMaxValue(): void
|
||||
{
|
||||
$value = explode('-', $this->validation);
|
||||
if ($this->fieldValue > (float)$value[1])
|
||||
$this->errorMessages[] = 'mag maximaal ' . $value[1] . ' zijn';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user