44 public function validate( array $properties, $tolerateMissing =
false ) {
45 foreach ( self::$propertyValidation as $property => $validation ) {
46 $path = explode(
'.', $property );
50 foreach (
$path as $p ) {
51 if ( !array_key_exists( $p, $val ) ) {
52 if ( $tolerateMissing ) {
56 return Status::newFatal(
'gadgets-validate-notset', $property );
63 $func = $validation[0];
64 if ( !call_user_func( $func, $val ) ) {
65 return Status::newFatal(
66 'gadgets-validate-wrongtype',
73 if ( isset( $validation[2] ) && is_array( $val ) ) {
75 $func = $validation[2];
76 foreach ( $val as $i => $v ) {
77 if ( !call_user_func( $func, $v ) ) {
78 return Status::newFatal(
79 'gadgets-validate-wrongtype',
89 return Status::newGood();