Add Enum validation for class constants
This commit is contained in:
19
source/lib/SihnonFramework/Validation/Enum.class.php
Normal file
19
source/lib/SihnonFramework/Validation/Enum.class.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
Class SihnonFramework_Validation_Enum extends SihnonFramework_Validation {
|
||||||
|
|
||||||
|
public static function validate($inputs, $class, $prefix) {
|
||||||
|
if ( ! is_array($inputs)) {
|
||||||
|
$inputs = array($inputs);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($inputs as $input) {
|
||||||
|
if ( ! SihnonFramework_Main::isClassConstantValue($class, $prefix, $input)) {
|
||||||
|
throw new SihnonFramework_Exception_InvalidContent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user