Required.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2016 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\validation\impl;
12 
14 
15 /**
16  * Required checks if the value is not empty.
17  *
18  * Configuration examples:
19  * @code
20  * required
21  * @endcode
22  *
23  * @author ingo herwig <ingo@wemove.com>
24  */
25 class Required implements ValidateType {
26 
27  /**
28  * @see ValidateType::validate
29  */
30  public function validate($value, $options=null, $context=null) {
31  return is_array($value) && count($value) > 0 || strlen($value) > 0;
32  }
33 }
34 ?>
Required checks if the value is not empty.
Definition: Required.php:25
ValidateType defines the interface for all validator classes.
validate($value, $options=null, $context=null)
Definition: Required.php:30