private static function validateOption($name, &$value) { $listSchema = (include __DIR__ . '/CollaborationListContentSchema.php'); // Special handling for DISPLAYMODE if ($name == 'DISPLAYMODE') { if ($value == 'members' || $value == 'normal' || $value == 'error') { return true; } return false; } // Force intrepretation as boolean for certain options if ($name == "includedesc") { $value = (bool) $value; } // Set up a dummy CollaborationListContent array featuring the options being validated $toValidate = ['displaymode' => 'normal', 'description' => '', 'columns' => [], 'options' => [$name => $value]]; return EventLogging::schemaValidate($toValidate, $listSchema); }
/** * Decode and validate the contents * @return bool Whether the contents are valid */ public function isValid() { $hubSchema = (include __DIR__ . '/CollaborationHubContentSchema.php'); $jsonParse = $this->getData(); if ($jsonParse->isGood()) { // TODO: The schema should be checking for required fields but for some reason that doesn't work if (!isset($jsonParse->value->content)) { return false; } // Forcing the object to become an array $jsonAsArray = json_decode(json_encode($jsonParse->getValue()), true); try { EventLogging::schemaValidate($jsonAsArray, $hubSchema); return true; } catch (JsonSchemaException $e) { return false; } return false; } return false; }