| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Routines used to validate and normalize arguments. | 5 // Routines used to validate and normalize arguments. |
| 6 | 6 |
| 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 7 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); |
| 8 | 8 |
| 9 // TODO(benwells): unit test this file. | 9 // TODO(benwells): unit test this file. |
| 10 // JSONSchemaValidator is not loaded in unit tests. | 10 // JSONSchemaValidator is not loaded in unit tests. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 message += "Property '" + err.path + "': "; | 29 message += "Property '" + err.path + "': "; |
| 30 } | 30 } |
| 31 message += err.message; | 31 message += err.message; |
| 32 message = message.substring(0, message.length - 1); | 32 message = message.substring(0, message.length - 1); |
| 33 message += ", "; | 33 message += ", "; |
| 34 } | 34 } |
| 35 message = message.substring(0, message.length - 2); | 35 message = message.substring(0, message.length - 2); |
| 36 message += "."; | 36 message += "."; |
| 37 throw new Error(message); | 37 throw new Error(message); |
| 38 } else if (!parameterSchemas[i].optional) { | 38 } else if (!parameterSchemas[i].optional) { |
| 39 throw new Error("Parameter " + (i + 1) + " is required."); | 39 throw new Error("Parameter " + (i + 1) + " (" + |
| 40 parameterSchemas[i].name + ") is required."); |
| 40 } | 41 } |
| 41 } | 42 } |
| 42 }; | 43 }; |
| 43 } else { | 44 } else { |
| 44 validate = function() {}; | 45 validate = function() {}; |
| 45 } | 46 } |
| 46 | 47 |
| 47 // Generate all possible signatures for a given API function. | 48 // Generate all possible signatures for a given API function. |
| 48 function getSignatures(parameterSchemas) { | 49 function getSignatures(parameterSchemas) { |
| 49 if (parameterSchemas.length === 0) | 50 if (parameterSchemas.length === 0) |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return true; | 153 return true; |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 return false; | 156 return false; |
| 156 }; | 157 }; |
| 157 | 158 |
| 158 exports.isFunctionSignatureAmbiguous = isFunctionSignatureAmbiguous; | 159 exports.isFunctionSignatureAmbiguous = isFunctionSignatureAmbiguous; |
| 159 exports.normalizeArgumentsAndValidate = normalizeArgumentsAndValidate; | 160 exports.normalizeArgumentsAndValidate = normalizeArgumentsAndValidate; |
| 160 exports.schemaValidator = schemaValidator; | 161 exports.schemaValidator = schemaValidator; |
| 161 exports.validate = validate; | 162 exports.validate = validate; |
| OLD | NEW |