This commit is contained in:
2018-01-10 14:09:34 +01:00
parent d1de2210e6
commit 6366bbc6a8
19 changed files with 776 additions and 162 deletions
@@ -85,8 +85,11 @@ class validation {
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();
}
}
@@ -170,6 +173,21 @@ class validation {
if ( ! $value ) $this->errorMessages[] = 'invoer moet uniek zijn';
}
public function checkDate()
{
if( empty($this->fieldValue) ) return;
$dateParts = explode('-', $this->fieldValue);
if( count($dateParts) != 3) $dateParts = explode('/', $this->fieldValue);
if( count($dateParts) != 3)
return $this->errorMessages[] = 'invoer is geen datum';
if( ! checkdate($dateParts[1], $dateParts[0], $dateParts[2] ))
$this->errorMessages[] = 'invoer is geen datum';
}
private function checkMinlength()
{
$length = explode( '-', $this->validation );
@@ -186,5 +204,21 @@ class validation {
$this->errorMessages[] = 'mag maximaal uit ' . $length[1] . ' karakters bestaan';
}
private function checkMinValue()
{
$value = explode( $this->validation, '-' );
if( $this->fieldValue < $value[1])
$this->errorMessages[] = 'moet minimaal ' . $value[1] . ' zijn';
}
private function checkMaxValue()
{
$value = explode( $this->validation, '-' );
if( $this->fieldValue > $value[1])
$this->errorMessages[] = 'mag maximaal ' . $value[1] . ' zijn';
}
}