[Utils] - Type ANY added
authorAndrzej Popowski <a.popowski@samsung.com>
Wed, 30 Mar 2016 09:38:23 +0000 (11:38 +0200)
committerAndrzej Popowski <a.popowski@samsung.com>
Wed, 30 Mar 2016 10:07:14 +0000 (12:07 +0200)
Change-Id: Ic56eb48eb7a84a4af918d9074f1a2b5a544eb9ef
Signed-off-by: Andrzej Popowski <a.popowski@samsung.com>
src/utils/utils_api.js

index 79403e07f8745532ce9ef1216482533001637016..6c81ff1dd17ce42ef30fd9008b8b41fc9c11eb26 100644 (file)
@@ -572,7 +572,8 @@ var Validator = function() {
     LISTENER: 'LISTENER',
     ARRAY: 'ARRAY',
     ENUM: 'ENUM',
-    FILE_REFERENCE: 'FILE_REFERENCE'
+    FILE_REFERENCE: 'FILE_REFERENCE',
+    SIMPLE_TYPE: 'SIMPLE_TYPE'    // Boolean, Number or String
   };
 };
 
@@ -834,6 +835,19 @@ Validator.prototype.validateArgs = function(a, d) {
           val = _converter.toString(val, nullable);
           break;
 
+        case this.Types.SIMPLE_TYPE:
+          if (optional && _type.isUndefined(val)) {
+            break;
+          }
+          if (nullable && _type.isNull(val)) {
+            break;
+          }
+          if (!_type.isBoolean(val) && !_type.isNumber(val) && !_type.isString(val)) {
+            throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
+                'Argument "' + name + '" should be boolean, number or string.');
+          }
+          break;
+
         default:
           throw new WebAPIException(WebAPIException.TYPE_MISMATCH_ERR,
               'Unknown type: "' + type + '".');