| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/json_schema/json_schema_validator.h" | 5 #include "components/json_schema/json_schema_validator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cfloat> | 10 #include <cfloat> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "components/json_schema/json_schema_constants.h" | 23 #include "components/json_schema/json_schema_constants.h" |
| 24 #include "third_party/re2/src/re2/re2.h" | 24 #include "third_party/re2/src/re2/re2.h" |
| 25 | 25 |
| 26 namespace schema = json_schema_constants; | 26 namespace schema = json_schema_constants; |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 double GetNumberValue(const base::Value* value) { | 30 double GetNumberValue(const base::Value* value) { |
| 31 double result = 0; | 31 double result = 0; |
| 32 CHECK(value->GetAsDouble(&result)) | 32 // Unexpected value type. |
| 33 << "Unexpected value type: " << value->GetType(); | 33 CHECK(value->GetAsDouble(&result)); |
| 34 return result; | 34 return result; |
| 35 } | 35 } |
| 36 | 36 |
| 37 bool IsValidType(const std::string& type) { | 37 bool IsValidType(const std::string& type) { |
| 38 static const char* kValidTypes[] = { | 38 static const char* kValidTypes[] = { |
| 39 schema::kAny, | 39 schema::kAny, |
| 40 schema::kArray, | 40 schema::kArray, |
| 41 schema::kBoolean, | 41 schema::kBoolean, |
| 42 schema::kInteger, | 42 schema::kInteger, |
| 43 schema::kNull, | 43 schema::kNull, |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 | 841 |
| 842 if (*additional_properties_schema) { | 842 if (*additional_properties_schema) { |
| 843 std::string additional_properties_type(schema::kAny); | 843 std::string additional_properties_type(schema::kAny); |
| 844 CHECK((*additional_properties_schema)->GetString( | 844 CHECK((*additional_properties_schema)->GetString( |
| 845 schema::kType, &additional_properties_type)); | 845 schema::kType, &additional_properties_type)); |
| 846 return additional_properties_type == schema::kAny; | 846 return additional_properties_type == schema::kAny; |
| 847 } else { | 847 } else { |
| 848 return default_allow_additional_properties_; | 848 return default_allow_additional_properties_; |
| 849 } | 849 } |
| 850 } | 850 } |
| OLD | NEW |