Lines Matching refs:schema
22 namespace schema = json_schema_constants;
90 scoped_ptr<base::DictionaryValue> schema(
94 ASSERT_TRUE(schema.get());
97 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
99 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
101 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1",
104 schema::kNumber,
105 schema::kObject));
112 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
119 scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
120 schema->SetString(schema::kType, schema::kString);
121 schema->SetString(schema::kPattern, "foo+");
125 schema.get(), NULL);
128 schema.get(), NULL);
131 schema.get(),
139 scoped_ptr<base::DictionaryValue> schema(LoadDictionary("enum_schema.json"));
143 schema.get(), NULL);
146 schema.get(), NULL);
149 schema.get(), NULL);
153 schema.get(),
159 schema.get(),
166 scoped_ptr<base::DictionaryValue> schema(
171 schema.get(), NULL);
174 schema.get(), NULL);
178 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
182 schema.get(),
188 schema.get(),
196 schema.get(),
207 scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
208 schema->SetString(schema::kType, schema::kObject);
209 schema->SetString("properties.foo.type", schema::kString);
210 schema->SetString("properties.bar.type", schema::kInteger);
216 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
219 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
224 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "bar",
228 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "bar",
231 schema::kInteger,
232 schema::kString));
237 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
239 schema->SetString("patternProperties.extra+.type",
240 schema::kInteger);
241 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
244 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
247 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
250 schema->Remove(schema::kPatternProperties, NULL);
254 schema->SetString("patternProperties.fo+.type", schema::kInteger);
255 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "foo",
258 schema::kInteger,
259 schema::kString));
261 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "foo",
264 schema::kString,
265 schema::kInteger));
267 schema->Remove(schema::kPatternProperties, NULL);
271 additional_properties->SetString(schema::kType, schema::kAny);
272 schema->Set(schema::kAdditionalProperties, additional_properties);
275 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
278 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
280 additional_properties->SetString(schema::kType, schema::kBoolean);
282 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
285 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
288 schema::kBoolean,
289 schema::kString));
294 ASSERT_TRUE(schema->GetDictionary(schema::kProperties, &properties));
297 bar_property->SetBoolean(schema::kOptional, true);
298 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
300 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
302 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
305 schema::kInteger,
306 schema::kNull));
308 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
311 schema::kInteger,
312 schema::kString));
315 schema.reset(LoadDictionary("pattern_properties_dot.json"));
316 ASSERT_TRUE(schema->GetDictionary(schema::kPatternProperties, &properties));
321 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
323 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL,
331 scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
332 schema->SetString(schema::kType, schema::kObject);
333 schema->SetString("properties.foo.type", schema::kString);
334 schema->SetString("properties.bar.$ref", "Max10Int");
335 schema->SetString("properties.baz.$ref", "MinLengthString");
338 schema_inline->SetString(schema::kType, schema::kObject);
339 schema_inline->SetString("properties.foo.type", schema::kString);
341 schema_inline->SetString("properties.bar.type", schema::kInteger);
356 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), types.get());
359 // Validation failure, but successful schema reference.
361 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), types.get(),
373 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), types.get(),
388 scoped_ptr<base::DictionaryValue> schema(
390 ASSERT_TRUE(schema.get());
396 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
401 schema.get(),
409 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1",
414 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0",
417 schema::kString,
418 schema::kInteger));
421 additional_properties->SetString(schema::kType, schema::kAny);
422 schema->Set(schema::kAdditionalProperties, additional_properties);
425 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
427 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
429 additional_properties->SetString(schema::kType, schema::kBoolean);
430 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "2",
433 schema::kBoolean,
434 schema::kArray));
436 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
440 ASSERT_TRUE(schema->GetList(schema::kItems, &items_schema));
442 item0_schema->SetBoolean(schema::kOptional, true);
444 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
448 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
450 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "0",
453 schema::kString,
454 schema::kInteger));
458 scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
459 schema->SetString(schema::kType, schema::kArray);
460 schema->SetString("items.type", schema::kString);
461 schema->SetInteger(schema::kMinItems, 2);
462 schema->SetInteger(schema::kMaxItems, 3);
468 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
470 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL);
475 schema.get(),
485 schema.get(),
493 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1",
496 schema::kString,
497 schema::kInteger));
501 scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
502 schema->SetString(schema::kType, schema::kString);
503 schema->SetInteger(schema::kMinLength, 1);
504 schema->SetInteger(schema::kMaxLength, 10);
508 schema.get(), NULL);
512 schema.get(), NULL);
517 schema.get(),
525 schema.get(),
533 scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
534 schema->SetString(schema::kType, schema::kNumber);
535 schema->SetInteger(schema::kMinimum, 1);
536 schema->SetInteger(schema::kMaximum, 100);
537 schema->SetInteger("maxDecimal", 2);
541 schema.get(), NULL);
544 schema.get(), NULL);
547 schema.get(), NULL);
550 schema.get(), NULL);
554 schema.get(),
562 schema.get(),
570 EXPECT_EQ(std::string(schema::kBoolean),
574 EXPECT_EQ(std::string(schema::kBoolean),
582 EXPECT_EQ(std::string(schema::kInteger),
585 EXPECT_EQ(std::string(schema::kInteger),
588 EXPECT_EQ(std::string(schema::kInteger),
591 EXPECT_EQ(std::string(schema::kInteger),
594 EXPECT_EQ(std::string(schema::kInteger),
600 EXPECT_EQ(std::string(schema::kNumber),
604 EXPECT_EQ(std::string(schema::kNumber),
607 EXPECT_EQ(std::string(schema::kNumber),
612 EXPECT_EQ(std::string(schema::kString),
615 EXPECT_EQ(std::string(schema::kArray),
618 EXPECT_EQ(std::string(schema::kObject),
621 EXPECT_EQ(std::string(schema::kNull),
627 scoped_ptr<base::DictionaryValue> schema(new base::DictionaryValue());
630 schema->SetString(schema::kType, schema::kObject);
633 schema.get(), NULL);
635 schema->SetString(schema::kType, schema::kArray);
637 schema.get(), NULL);
639 schema->SetString(schema::kType, schema::kString);
642 schema.get(), NULL);
644 schema->SetString(schema::kType, schema::kNumber);
647 schema.get(), NULL);
650 schema.get(), NULL);
653 schema.get(), NULL);
656 schema.get(), NULL);
658 schema->SetString(schema::kType, schema::kInteger);
661 schema.get(), NULL);
664 schema.get(), NULL);
667 schema.get(), NULL);
671 schema.get(), NULL);
675 schema.get(), NULL);
677 schema->SetString(schema::kType, schema::kBoolean);
680 schema.get(), NULL);
683 schema.get(), NULL);
685 schema->SetString(schema::kType, schema::kNull);
688 schema.get(), NULL);
691 schema->SetString(schema::kType, schema::kObject);
695 schema.get(),
699 JSONSchemaValidator::kInvalidType, schema::kObject, schema::kArray));
701 schema->SetString(schema::kType, schema::kObject);
705 schema.get(),
709 JSONSchemaValidator::kInvalidType, schema::kObject, schema::kNull));
711 schema->SetString(schema::kType, schema::kArray);
715 schema.get(),
719 JSONSchemaValidator::kInvalidType, schema::kArray, schema::kInteger));
721 schema->SetString(schema::kType, schema::kString);
725 schema.get(),
729 schema::kString,
730 schema::kInteger));
732 schema->SetString(schema::kType, schema::kNumber);
736 schema.get(),
740 JSONSchemaValidator::kInvalidType, schema::kNumber, schema::kString));
742 schema->SetString(schema::kType, schema::kInteger);
746 schema.get(),
751 schema->SetString(schema::kType, schema::kBoolean);
755 schema.get(),
759 schema::kBoolean,
760 schema::kInteger));
762 schema->SetString(schema::kType, schema::kNull);
766 schema.get(),
770 JSONSchemaValidator::kInvalidType, schema::kNull, schema::kBoolean));