Lines Matching refs:instance
164 bool JSONSchemaValidator::Validate(Value* instance) {
166 Validate(instance, schema_root_, "");
170 void JSONSchemaValidator::Validate(Value* instance,
183 // If the schema has a $ref property, the instance must validate against
192 Validate(instance, type->second, path);
197 // If the schema has a choices property, the instance must validate against at
201 ValidateChoices(instance, choices, path);
205 // If the schema has an enum property, the instance must be one of those
209 ValidateEnum(instance, enumeration, path);
217 if (!ValidateType(instance, type, path))
222 ValidateObject(static_cast<DictionaryValue*>(instance), schema, path);
224 ValidateArray(static_cast<ListValue*>(instance), schema, path);
226 ValidateString(static_cast<StringValue*>(instance), schema, path);
228 ValidateNumber(instance, schema, path);
234 void JSONSchemaValidator::ValidateChoices(Value* instance,
243 Validate(instance, choice, path);
257 void JSONSchemaValidator::ValidateEnum(Value* instance,
267 if (instance->Equals(choice))
273 if (instance->IsType(Value::TYPE_INTEGER) ||
274 instance->IsType(Value::TYPE_DOUBLE)) {
275 if (GetNumberValue(choice) == GetNumberValue(instance))
288 void JSONSchemaValidator::ValidateObject(DictionaryValue* instance,
301 if (instance->Get(*key, &prop_value)) {
320 for (DictionaryValue::key_iterator key = instance->begin_keys();
321 key != instance->end_keys(); ++key) {
330 CHECK(instance->Get(*key, &prop_value));
336 void JSONSchemaValidator::ValidateArray(ListValue* instance,
340 size_t instance_size = instance->GetSize();
364 CHECK(instance->Get(i, &item));
375 ValidateTuple(instance, schema, path);
378 void JSONSchemaValidator::ValidateTuple(ListValue* instance,
391 instance->Get(i, &item_value);
409 size_t instance_size = instance->GetSize();
417 CHECK(instance->Get(i, &item_value));
426 void JSONSchemaValidator::ValidateString(StringValue* instance,
430 CHECK(instance->GetAsString(&value));
453 void JSONSchemaValidator::ValidateNumber(Value* instance,
456 double value = GetNumberValue(instance);
476 bool JSONSchemaValidator::ValidateType(Value* instance,
479 std::string actual_type = GetJSONSchemaType(instance);