MediaWiki REL1_33
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.
 

Static Public Member Functions

static isArrayOrTrue ( $value)
 

Static Protected Attributes

static $propertyValidation
 Validation metadata.
 

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.

References $value, and and().

◆ 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 $property, and and().

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' ],
]
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy

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: