Validators for Form Fields
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<?php include_once "../../../base/meta.php" ?>
|
||||
|
||||
<title>FormValidator Test</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php
|
||||
include_once "../../../base/settings.php";
|
||||
include_once "../../../base/headers.php";
|
||||
Headers::html();
|
||||
|
||||
//Testdatei für die Klasse FormValidator
|
||||
include_once "../classes/fieldValidator/fieldValidator.php";
|
||||
include_once "../classes/formValidator/formValidator.php";
|
||||
|
||||
$form = FormValidator::create(
|
||||
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 ($form->getErrors() as $error) {
|
||||
echo "$error<br />";
|
||||
}
|
||||
|
||||
?>
|
||||
<br />
|
||||
<pre>
|
||||
<?php
|
||||
print_r($form->getField("E-Mail Valid"));
|
||||
echo "\n\n";
|
||||
print_r($form->getField("Name"));
|
||||
?>
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user