Skip to content

Commit 6875108

Browse files
committed
Fixed Required validator if used for arrays
1 parent 68c5ad1 commit 6875108

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/wcmf/lib/validation/impl/Filter.php

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
*
2828
* // FILTER_VALIDATE_REGEXP with regexp option
2929
* filter:{"type":"validate_regexp","options":{"options":{"regexp":"/^[0-9]*$/"}}}
30+
*
31+
* // FILTER_UNSAFE_RAW with FILTER_REQUIRE_ARRAY flag
32+
* filter:{"type":"unsafe_raw","options":16777216}
3033
* @endcode
3134
*
3235
* @author ingo herwig <[email protected]>

src/wcmf/lib/validation/impl/Required.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Required implements ValidateType {
2828
* @see ValidateType::validate
2929
*/
3030
public function validate($value, $options=null, $context=null) {
31-
return strlen($value) > 0;
31+
return is_array($value) && count($value) > 0 || strlen($value) > 0;
3232
}
3333
}
3434
?>

0 commit comments

Comments
 (0)