Validators for Form Fields
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<?php include_once "../../../base/meta.php" ?>
|
||||
|
||||
<title>FieldValidator Test</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include_once "../../../base/settings.php";
|
||||
include_once "../../../base/headers.php";
|
||||
Headers::html();
|
||||
|
||||
//Testdatei für die Klasse FieldValidator
|
||||
include_once "../classes/fieldValidator/fieldValidator.php";
|
||||
|
||||
$validators = [
|
||||
FieldValidator::create("Empty Valid", "", "string"),
|
||||
FieldValidator::create("Empty Invalid", "", "string")->isRequired(),
|
||||
FieldValidator::create("MinLen Valid", "ssss", "string")->withMinLen(4),
|
||||
FieldValidator::create("MinLen Invalid", "sss", "string")->withMinLen(4),
|
||||
FieldValidator::create("MaxLen Valid", "ssss", "string")->withMaxLen(4),
|
||||
FieldValidator::create("MaxLen Invalid", "sssss", "string")->withMaxLen(4),
|
||||
FieldValidator::create("E-Mail Valid", "khofmann@fu-berlin.de", "email"),
|
||||
FieldValidator::create("E-Mail Invalid", "khofmann@fu-berlin de", "email"),
|
||||
];
|
||||
|
||||
foreach ($validators as $validator) {
|
||||
echo "<b>" . $validator->getName() . "</b>: ";
|
||||
echo $validator->isValid() ? "<em>True</em>" : "<em>False</em>" . " with " . $validator->getError();
|
||||
echo "<br />";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user