MediaWiki  1.34.0
GadgetDefinitionValidator Class Reference

Class responsible for validating Gadget definition contents. More...

Public Member Functions

 validate (array $properties, $tolerateMissing=false)
 Check the validity of the given properties array. More...
 

Static Public Member Functions

static isArrayOrTrue ( $value)
 

Static Protected Attributes

static $propertyValidation
 Validation metadata. More...
 

Detailed Description

Class responsible for validating Gadget definition contents.

Todo:
maybe this should use a formal JSON schema validator or something

Definition at line 8 of file GadgetDefinitionValidator.php.

Member Function Documentation

◆ isArrayOrTrue()

static GadgetDefinitionValidator::isArrayOrTrue (   $value)
static
Parameters
mixed$value
Returns
bool

Definition at line 34 of file GadgetDefinitionValidator.php.

◆ validate()

GadgetDefinitionValidator::validate ( array  $properties,
  $tolerateMissing = false 
)

Check the validity of the given properties array.

Parameters
array$propertiesReturn value of FormatJson::decode( $blob, true )
bool$tolerateMissingIf true, don't complain about missing keys
Returns
Status object with error message if applicable

Definition at line 44 of file GadgetDefinitionValidator.php.

References $path, StatusValue\newFatal(), and StatusValue\newGood().

Member Data Documentation

◆ $propertyValidation

GadgetDefinitionValidator::$propertyValidation
staticprotected
Initial value:
= [
'settings' => [ 'is_array', 'array' ],
'settings.rights' => [ 'is_array', 'array' , 'is_string', 'string' ],
'settings.default' => [ 'is_bool', 'boolean' ],
'settings.hidden' => [ 'is_bool', 'boolean' ],
'settings.skins' => [ [ __CLASS__, 'isArrayOrTrue' ], 'array or true', 'is_string', 'string' ],
'settings.category' => [ 'is_string', 'string' ],
'module' => [ 'is_array', 'array' ],
'module.scripts' => [ 'is_array', 'array', 'is_string', 'string' ],
'module.styles' => [ 'is_array', 'array', 'is_string', 'string' ],
'module.dependencies' => [ 'is_array', 'array', 'is_string', 'string' ],
'module.peers' => [ 'is_array', 'array', 'is_string', 'string' ],
'module.messages' => [ 'is_array', 'array', 'is_string', 'string' ],
'module.type' => [ 'is_string', 'string' ],
]

Validation metadata.

'foo.bar.baz' => [ 'type check callback', 'type name' [, 'member type check callback', 'member type name'] ]

Definition at line 14 of file GadgetDefinitionValidator.php.


The documentation for this class was generated from the following file: