Lines Matching refs:schema
22 namespace schema = json_schema_constants;
35 schema::kAny,
36 schema::kArray,
37 schema::kBoolean,
38 schema::kInteger,
39 schema::kNull,
40 schema::kNumber,
41 schema::kObject,
42 schema::kString,
48 // Maps a schema attribute name to its expected type.
77 // Note: kRef == "$ref", kSchema == "$schema"
78 { schema::kRef, base::Value::TYPE_STRING },
79 { schema::kSchema, base::Value::TYPE_STRING },
81 { schema::kAdditionalProperties, base::Value::TYPE_DICTIONARY },
82 { schema::kChoices, base::Value::TYPE_LIST },
83 { schema::kDescription, base::Value::TYPE_STRING },
84 { schema::kEnum, base::Value::TYPE_LIST },
85 { schema::kId, base::Value::TYPE_STRING },
86 { schema::kMaxItems, base::Value::TYPE_INTEGER },
87 { schema::kMaxLength, base::Value::TYPE_INTEGER },
88 { schema::kMaximum, base::Value::TYPE_DOUBLE },
89 { schema::kMinItems, base::Value::TYPE_INTEGER },
90 { schema::kMinLength, base::Value::TYPE_INTEGER },
91 { schema::kMinimum, base::Value::TYPE_DOUBLE },
92 { schema::kOptional, base::Value::TYPE_BOOLEAN },
93 { schema::kPattern, base::Value::TYPE_STRING },
94 { schema::kPatternProperties, base::Value::TYPE_DICTIONARY },
95 { schema::kProperties, base::Value::TYPE_DICTIONARY },
96 { schema::kTitle, base::Value::TYPE_STRING },
106 if (it.key() == schema::kType) {
133 // Validate the "items" attribute, which is a schema or a list of schemas.
134 if (it.key() == schema::kItems) {
192 // Validate the "properties" attribute. Each entry maps a key to a schema.
193 if (it.key() == schema::kProperties) {
209 // expression to a schema. The validity of the regular expression expression
212 if (it.key() == schema::kPatternProperties) {
227 // Validate "additionalProperties" attribute, which is a schema.
228 if (it.key() == schema::kAdditionalProperties) {
237 if (it.key() == schema::kEnum) {
264 if (it.key() == schema::kChoices) {
278 if (it.key() == schema::kRef)
283 *error = "Schema must have a type or a $ref attribute";
307 "Unknown schema reference: *.";
344 return schema::kNull;
346 return schema::kBoolean;
348 return schema::kInteger;
354 return schema::kInteger;
356 return schema::kNumber;
360 return schema::kString;
362 return schema::kObject;
364 return schema::kArray;
391 const std::string& schema,
393 return JSONSchemaValidator::IsValidSchema(schema, 0, error);
398 const std::string& schema,
403 base::JSONReader::ReadAndReturnError(schema, json_options, NULL, error));
408 *error = "Schema must be a JSON object";
417 JSONSchemaValidator::JSONSchemaValidator(base::DictionaryValue* schema)
418 : schema_root_(schema), default_allow_additional_properties_(false) {
421 JSONSchemaValidator::JSONSchemaValidator(base::DictionaryValue* schema,
423 : schema_root_(schema), default_allow_additional_properties_(false) {
432 CHECK(type->GetString(schema::kId, &id));
448 const base::DictionaryValue* schema,
450 // If this schema defines itself as reference type, save it in this.types.
452 if (schema->GetString(schema::kId, &id)) {
455 types_[id] = schema;
457 DCHECK(iter->second == schema);
460 // If the schema has a $ref property, the instance must validate against
461 // that schema. It must be present in types_ to be referenced.
463 if (schema->GetString(schema::kRef, &ref)) {
474 // If the schema has a choices property, the instance must validate against at
477 if (schema->GetList(schema::kChoices, &choices)) {
482 // If the schema has an enum property, the instance must be one of those
485 if (schema->GetList(schema::kEnum, &enumeration)) {
491 schema->GetString(schema::kType, &type);
493 if (type != schema::kAny) {
498 if (type == schema::kObject) {
500 schema,
502 } else if (type == schema::kArray) {
504 schema, path);
505 } else if (type == schema::kString) {
508 ValidateString(instance, schema, path);
509 } else if (type == schema::kNumber || type == schema::kInteger) {
510 ValidateNumber(instance, schema, path);
511 } else if (type != schema::kBoolean && type != schema::kNull) {
578 const base::DictionaryValue* schema,
581 if (schema->GetDictionary(schema::kProperties, &properties)) {
595 prop_schema->GetBoolean(schema::kOptional, &is_optional);
605 SchemaAllowsAnyAdditionalItems(schema, &additional_properties_schema);
611 if (schema->GetDictionary(schema::kPatternProperties, &pattern_properties)) {
659 const base::DictionaryValue* schema,
663 if (schema->GetDictionary(schema::kItems, &single_type)) {
665 if (schema->GetInteger(schema::kMinItems, &min_items)) {
674 if (schema->GetInteger(schema::kMaxItems, &max_items)) {
682 // If the items property is a single schema, each item in the array must
683 // validate against that schema.
696 // particular schema.
697 ValidateTuple(instance, schema, path);
701 const base::DictionaryValue* schema,
704 schema->GetList(schema::kItems, &tuple_type);
718 item_schema->GetBoolean(schema::kOptional, &is_optional);
728 if (SchemaAllowsAnyAdditionalItems(schema, &additional_properties_schema))
734 // schema.
749 const base::DictionaryValue* schema,
755 if (schema->GetInteger(schema::kMinLength, &min_length)) {
764 if (schema->GetInteger(schema::kMaxLength, &max_length)) {
773 if (schema->GetString(schema::kPattern, &pattern)) {
789 const base::DictionaryValue* schema,
797 if (schema->GetDouble(schema::kMinimum, &minimum)) {
804 if (schema->GetDouble(schema::kMaximum, &maximum)) {
816 (expected_type == schema::kNumber && actual_type == schema::kInteger)) {
818 } else if (expected_type == schema::kInteger &&
819 actual_type == schema::kNumber) {
830 const base::DictionaryValue* schema,
832 // If the validator allows additional properties globally, and this schema
834 schema->GetDictionary(schema::kAdditionalProperties,
838 std::string additional_properties_type(schema::kAny);
840 schema::kType, &additional_properties_type));
841 return additional_properties_type == schema::kAny;