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 <algorithm> | 7 #include <algorithm> |
8 #include <cfloat> | 8 #include <cfloat> |
9 #include <cmath> | 9 #include <cmath> |
10 #include <vector> | 10 #include <vector> |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 default: | 365 default: |
366 NOTREACHED() << "Unexpected value type: " << value->GetType(); | 366 NOTREACHED() << "Unexpected value type: " << value->GetType(); |
367 return std::string(); | 367 return std::string(); |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 // static | 371 // static |
372 std::string JSONSchemaValidator::FormatErrorMessage(const std::string& format, | 372 std::string JSONSchemaValidator::FormatErrorMessage(const std::string& format, |
373 const std::string& s1) { | 373 const std::string& s1) { |
374 std::string ret_val = format; | 374 std::string ret_val = format; |
375 ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); | 375 base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); |
376 return ret_val; | 376 return ret_val; |
377 } | 377 } |
378 | 378 |
379 // static | 379 // static |
380 std::string JSONSchemaValidator::FormatErrorMessage(const std::string& format, | 380 std::string JSONSchemaValidator::FormatErrorMessage(const std::string& format, |
381 const std::string& s1, | 381 const std::string& s1, |
382 const std::string& s2) { | 382 const std::string& s2) { |
383 std::string ret_val = format; | 383 std::string ret_val = format; |
384 ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); | 384 base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s1); |
385 ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2); | 385 base::ReplaceFirstSubstringAfterOffset(&ret_val, 0, "*", s2); |
386 return ret_val; | 386 return ret_val; |
387 } | 387 } |
388 | 388 |
389 // static | 389 // static |
390 scoped_ptr<base::DictionaryValue> JSONSchemaValidator::IsValidSchema( | 390 scoped_ptr<base::DictionaryValue> JSONSchemaValidator::IsValidSchema( |
391 const std::string& schema, | 391 const std::string& schema, |
392 std::string* error) { | 392 std::string* error) { |
393 return JSONSchemaValidator::IsValidSchema(schema, 0, error); | 393 return JSONSchemaValidator::IsValidSchema(schema, 0, error); |
394 } | 394 } |
395 | 395 |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
836 | 836 |
837 if (*additional_properties_schema) { | 837 if (*additional_properties_schema) { |
838 std::string additional_properties_type(schema::kAny); | 838 std::string additional_properties_type(schema::kAny); |
839 CHECK((*additional_properties_schema)->GetString( | 839 CHECK((*additional_properties_schema)->GetString( |
840 schema::kType, &additional_properties_type)); | 840 schema::kType, &additional_properties_type)); |
841 return additional_properties_type == schema::kAny; | 841 return additional_properties_type == schema::kAny; |
842 } else { | 842 } else { |
843 return default_allow_additional_properties_; | 843 return default_allow_additional_properties_; |
844 } | 844 } |
845 } | 845 } |
OLD | NEW |