comprodls-sdk 2.90.3-development → 2.91.0-thor

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +1 -137
  2. package/dist/comprodls-sdk.js +2917 -6291
  3. package/dist/comprodls-sdk.min.js +1 -1
  4. package/lib/comprodls.js +39 -57
  5. package/lib/config/index.js +172 -198
  6. package/lib/helpers/index.js +3 -2
  7. package/lib/helpers/lib/api/converter.js +1 -2
  8. package/lib/helpers/lib/api/index.js +19 -94
  9. package/lib/helpers/lib/errors.js +75 -80
  10. package/lib/helpers/lib/requestLayer.js +154 -0
  11. package/lib/helpers/lib/validator.js +65 -52
  12. package/lib/open_access/index.js +48 -53
  13. package/lib/services/analytics/index.js +286 -1014
  14. package/lib/services/attempts/index.js +38 -88
  15. package/lib/services/auth/index.js +324 -806
  16. package/lib/services/authextn/index.js +85 -247
  17. package/lib/services/datasyncmanager/index.js +10 -45
  18. package/lib/services/drive/index.js +20 -83
  19. package/lib/services/integrations/index.js +51 -126
  20. package/lib/services/invitations/index.js +20 -61
  21. package/lib/services/product/index.js +82 -85
  22. package/lib/services/pub/index.js +167 -235
  23. package/lib/services/pushX/index.js +195 -142
  24. package/lib/services/pushX/pubnubClientWrapper.js +399 -172
  25. package/lib/services/rules/index.js +14 -67
  26. package/lib/services/spaces/index.js +106 -289
  27. package/lib/services/spacesextn/index.js +44 -20
  28. package/lib/services/superuser/index.js +21 -36
  29. package/lib/services/taxonomy/index.js +27 -57
  30. package/lib/services/workflows/index.js +38 -97
  31. package/lib/services/xapi/index.js +7 -168
  32. package/lib/token/index.js +73 -67
  33. package/lib/token/validations.js +45 -48
  34. package/package.json +2 -3
  35. package/lib/helpers/lib/api/validations.js +0 -73
  36. package/lib/helpers/lib/utils.js +0 -24
  37. package/lib/services/activity/activity.js +0 -209
  38. package/lib/services/activity/attempt.js +0 -431
  39. package/lib/services/activity/index.js +0 -28
  40. package/lib/services/auth/classProduct.js +0 -37
  41. package/lib/services/collab/index.js +0 -468
  42. package/test.js +0 -38
@@ -17,105 +17,30 @@
17
17
  * is strictly forbidden unless prior written permission is obtained
18
18
  * from Compro Technologies Pvt. Ltd..
19
19
  ***************************************************************************/
20
- /***********************************************************
21
- * comproDLS SDK Generic API Caller
22
- * This module provides generic function(s) to call any comproDLS API.
23
- * The generic approach for calling API(s) require a prior knowledge of
24
- * the specific URLs and parameters (as per the API documentation).
25
- ************************************************************/
26
- var request = require('superagent');
27
- var q = require('q');
28
- var format = require("string-template");
20
+ var format = require('string-template');
29
21
 
30
- var config = require('../../../config');
31
- var helpers = require('../../../helpers');
32
- var errors = require('../errors');
33
- var DLSError = errors.DLSError;
34
- var validations = require('./validations');
35
-
36
- /*********************************
37
- * Setting up Exports/Public functions
38
- **********************************/
39
- exports.genericAPICaller = genericAPICaller;
40
22
  exports.constructAPIUrl = constructAPIUrl;
41
23
  exports.setupAPIToken = setupAPIToken;
42
- exports.addClassIdQueryParam = addClassIdQueryParam
43
-
44
- /*********************************
45
- * Public Function definitions
46
- **********************************/
47
-
48
- //Generic comproDLS API caller
49
- function genericAPICaller(apiName, method, url, params) {
50
- var self = this;
51
- var dfd = q.defer();
52
-
53
- //Validation
54
- var err = validations.genericAPICaller(apiName, method, url, params) || helpers.validations.isAuthenticated(self.orgId, self.token);
55
- if (err) {
56
- dfd.reject(err);
57
- } else {
58
-
59
- //Passed all validations, setup API Url and parameters
60
- var url = config.DEFAULT_HOSTS[apiName.toUpperCase()] + url;
61
-
62
- //Setup Delete method for superagent
63
- if (method === 'DELETE') {
64
- method = 'DEL';
65
- }
66
-
67
- var requestAPI = request(method, url);
68
-
69
- //Setting token in Authorization header
70
- requestAPI = setupAPIToken(requestAPI, self.token);
71
24
 
72
- //Setup request parameters
73
- if (Object.keys(params).length) {
74
- if (method === 'GET' || method === 'HEAD') {
75
- requestAPI = requestAPI.query(params);
76
- } else {
77
- requestAPI = requestAPI.send(params);
78
- }
79
- }
80
-
81
- //Call Specified API
82
- requestAPI.end(function(err, response) {
83
- if (err) {
84
- err = new DLSError(errors.ERROR_TYPES.API_ERROR, err);
85
- dfd.reject(err);
86
- } else {
87
- dfd.resolve(response.body);
88
- }
89
- });
90
- }
91
- return dfd.promise;
92
- };
93
-
94
- /*********************************************************
95
- * This function constructs the url of comproDLS API.
96
- * Options: JSON Object having actual values to replace in API URLs
97
- * Following are valid feilds in options object:
98
- {
99
- "orgId" : "",
100
- "productId" : "",
101
- "userId" : "",
102
- "activityId" : "",
103
- "attemptId" : "",
104
- "questionId" : ""
105
- }
106
- *********************************************************/
25
+ /**
26
+ * This function constructs the url of comproDLS API.
27
+ * @param {String} url - comproDLS API URL with placeholders
28
+ * @param {Object} options - JSON Object having actual values to replace in API URLs
29
+ * @returns
30
+ */
107
31
  function constructAPIUrl(url, options) {
108
- return format(url, options);
32
+ return format(url, options);
109
33
  };
110
34
 
111
- function addClassIdQueryParam(url, classId) {
112
- var queryParam = '';
113
- if(typeof(classId) !== "undefined" && classId !== null)
114
- queryParam = '?classId=' + classId;
115
- return url + queryParam;
116
- };
117
-
118
- //This function sets up comproDLS API token in request header
35
+ /**
36
+ * [Deprecated] This function is no longer needed. Use requestLayer functions instead,
37
+ * as the API token is now automatically handled by requestLayer.
38
+ *
39
+ * This function sets up the API token in the request header.
40
+ * @param {Object} request - The request object to which the token will be added
41
+ * @param {Object} token - The token object containing the access_token
42
+ * @returns {*} The modified request object with the Authorization header set
43
+ */
119
44
  function setupAPIToken(request, token) {
120
- return request.set('Authorization', token.access_token);
121
- };
45
+ return request.set('Authorization', token.access_token);
46
+ };
@@ -17,113 +17,108 @@
17
17
  * is strictly forbidden unless prior written permission is obtained
18
18
  * from Compro Technologies Pvt. Ltd..
19
19
  ***************************************************************************/
20
+
20
21
  /***********************************************************
21
22
  * comproDLS SDK Error Helper Module
22
23
  * This module contains helper functions for Error management
23
24
  ************************************************************/
24
25
 
25
- //All possible Error types in SDK
26
+ // All possible Error types in SDK
26
27
  var ERROR_TYPES = {
27
- "API_ERROR": "API_ERROR",
28
- "SDK_ERROR": "SDK_ERROR",
29
- "CHANNEL_SUBSCRIPTION": "CHANNEL_SUBSCRIPTION"
28
+ API_ERROR: 'API_ERROR',
29
+ SDK_ERROR: 'SDK_ERROR',
30
+ CHANNEL_SUBSCRIPTION: 'CHANNEL_SUBSCRIPTION',
31
+ UNEXPECTED_ERROR: 'UNEXPECTED_ERROR',
32
+ POLLING_INITIATION: 'POLLING_INITIATION'
30
33
  };
31
34
 
32
35
  var ERROR_CATEGORY = {
33
- PUSHX: 'PUSHX'
36
+ PUSHX: 'PUSHX'
34
37
  };
35
38
 
36
-
37
39
  var ERROR_STATUS = {
38
- ERROR: 'ERROR'
40
+ ERROR: 'ERROR'
39
41
  };
40
42
 
41
- /****************************************************
42
- * Setting up Exports/Public functions and variables
43
- *****************************************************/
44
43
  exports.DLSError = DLSError;
45
44
  exports.PUSHXError = PUSHXError;
46
45
  exports.ERROR_TYPES = ERROR_TYPES;
47
46
  exports.ERROR_CATEGORY = ERROR_CATEGORY;
48
47
 
49
- /*****************************************
50
- * Constructor for the DLS error object
51
- * Parameters:
52
- * type: Error Type. Possible values are SDK_ERROR and API_ERROR
53
- * err: JSON Error object. This can be:
54
- * 1. HTTP Error Object returned by comproDLS APIs (In case of API_ERROR)
55
- * 2. Custom Error Object(SDK_ERROR or Custom API_ERROR) with following structure
56
- * {
57
- * "message":"[String]",
58
- * "description":"[String]"
59
- * }
60
- ******************************************/
48
+ /**
49
+ * Constructor for the DLS error object
50
+ * Parameters:
51
+ * type: Error Type. Possible values are SDK_ERROR and API_ERROR
52
+ * err: JSON Error object. This can be:
53
+ * 1. HTTP Error Object returned by comproDLS APIs (In case of API_ERROR)
54
+ * 2. Custom Error Object(SDK_ERROR or Custom API_ERROR) with following structure
55
+ * {
56
+ * message: 'string',
57
+ * description: 'string'
58
+ * }
59
+ */
61
60
  function DLSError(type, err) {
62
- /*
63
- * We assume only two types of errors: SDK_ERROR (default)
64
- * or API_ERROR
65
- */
66
- this.type = type;
67
- if (type === ERROR_TYPES.API_ERROR) {
68
-
69
- //Depending on type of error (HTTP response or Custom) deal with different formats of the err object
70
- var msg, desc;
71
- if(err.response != undefined) {
72
- msg = err.response.body.message || err.response.body.dbErrorBody || err.response.body.code;
73
- desc = err.response.body.dbErrorDescription;
74
-
75
- // Add swagger errors
76
- if(err.response.body.results && err.response.body.results.errors) {
77
- msg = '';
78
- for(var idx in err.response.body.results.errors) {
79
- msg += err.response.body.results.errors[idx].message + ' ';
80
- }
81
- }
61
+ // We assume only two types of errors: SDK_ERROR (default) or API_ERROR
62
+ this.type = type;
63
+ if (type === ERROR_TYPES.API_ERROR) {
82
64
 
83
- // Add request_id
84
- if(err.response.body.server) {
85
- this.server = err.response.body.server;
86
- }
65
+ // Handling error on the basis of type of error (HTTP response or Custom)
66
+ var msg, desc;
67
+ if(err.response != undefined) {
68
+ msg = err.response.body.message || err.response.body.dbErrorBody || err.response.body.code;
69
+ desc = err.response.body.dbErrorDescription;
87
70
 
88
- } else {
89
- msg = err.message ? err.message : "";
90
- desc = err.description ? err.description : "";
71
+ // Add swagger errors
72
+ if (err.response.body.results && err.response.body.results.errors) {
73
+ msg = '';
74
+ for (var idx in err.response.body.results.errors) {
75
+ msg += err.response.body.results.errors[idx].message + ' ';
91
76
  }
77
+ }
92
78
 
93
- //Set the message and description
94
- this.message = msg;
95
- this.description = desc;
96
- }
97
- else if(type === ERROR_TYPES.PUSHX_ERROR) {
79
+ // Add request_id
80
+ if (err.response.body.server) {
81
+ this.server = err.response.body.server;
82
+ }
98
83
 
99
- //Set the message and description
100
- this.message = err.message;
101
- this.data = err;
102
- }
103
- else {
104
- this.message = err.message ? err.message : "";
105
- this.description = err.description ? err.description : "";
106
- delete err.message;
107
- delete err.description;
108
- this.data = err;
109
- }
110
-
111
- if (type === ERROR_TYPES.API_ERROR || type === ERROR_TYPES.PUSHX_ERROR) {
112
- this.httpcode = err.status;
84
+ } else {
85
+ msg = err.message ? err.message : '';
86
+ desc = err.description ? err.description : '';
113
87
  }
88
+
89
+ //Set the message and description
90
+ this.message = msg;
91
+ this.description = desc;
92
+ }
93
+ else if (type === ERROR_TYPES.PUSHX_ERROR) {
94
+ //Set the message and description
95
+ this.message = err.message;
96
+ this.data = err;
97
+ }
98
+ else {
99
+ this.message = err.message ? err.message : '';
100
+ this.description = err.description ? err.description : '';
101
+ delete err.message;
102
+ delete err.description;
103
+ this.data = err;
104
+ }
105
+
106
+ if (type === ERROR_TYPES.API_ERROR || type === ERROR_TYPES.PUSHX_ERROR) {
107
+ this.httpcode = err.status;
108
+ }
114
109
  };
115
110
 
116
111
  function PUSHXError(category, error) {
117
-
118
- if (category === ERROR_CATEGORY.PUSHX) {
119
- this.category = ERROR_CATEGORY.PUSHX;
120
- this.type = ERROR_TYPES.CHANNEL_SUBSCRIPTION;
121
- this.status = ERROR_STATUS.ERROR;
122
- this.message = error.message;
123
- this.data = error;
124
- this.httpcode = (error.errorDetails && error.errorDetails.statusCode) ? error.errorDetails.statusCode : 500;
125
- }
126
- else {
127
- this.message = 'PUSHXError called for incorrect category.';
128
- }
112
+ if (category === ERROR_CATEGORY.PUSHX) {
113
+ this.category = ERROR_CATEGORY.PUSHX;
114
+ this.type = error.type || ERROR_TYPES.CHANNEL_SUBSCRIPTION;
115
+ this.status = ERROR_STATUS.ERROR;
116
+ this.message = error.message;
117
+ this.data = error;
118
+ this.httpcode = (error.errorDetails && error.errorDetails.statusCode) ?
119
+ error.errorDetails.statusCode : 500;
120
+ }
121
+ else {
122
+ this.message = 'PUSHXError called for incorrect category.';
123
+ }
129
124
  };
@@ -0,0 +1,154 @@
1
+ /*************************************************************************
2
+ *
3
+ * COMPRO CONFIDENTIAL
4
+ * __________________
5
+ *
6
+ * [2015] - [2020] Compro Technologies Private Limited
7
+ * All Rights Reserved.
8
+ *
9
+ * NOTICE: All information contained herein is, and remains
10
+ * the property of Compro Technologies Private Limited. The
11
+ * intellectual and technical concepts contained herein are
12
+ * proprietary to Compro Technologies Private Limited and may
13
+ * be covered by U.S. and Foreign Patents, patents in process,
14
+ * and are protected by trade secret or copyright law.
15
+ *
16
+ * Dissemination of this information or reproduction of this material
17
+ * is strictly forbidden unless prior written permission is obtained
18
+ * from Compro Technologies Pvt. Ltd..
19
+ ***************************************************************************/
20
+
21
+ var Request = require('superagent');
22
+ var Agent = require('agentkeepalive');
23
+
24
+ var keepaliveAgent = new Agent({
25
+ timeout: 60000,
26
+ freeSocketTimeout: 30000
27
+ });
28
+
29
+ /**
30
+ * Sends an HTTP GET request to the specified URL with query parameters and optional headers.
31
+ *
32
+ * @param {string} url - The endpoint to send the request to.
33
+ * @param {Object} options.params - Query parameters to append to the URL.
34
+ * @param {Object} options.headers - Optional headers including traceid and token.
35
+ */
36
+ function getRequest(url, options) {
37
+ var params = options.params, headers = options.headers;
38
+
39
+ return new Promise(function (resolve, reject) {
40
+ // Setup request with URL and Params
41
+ var requestAPI = Request.get(url)
42
+ .set('Accept', 'application/json')
43
+ .query(params);
44
+
45
+ // Setting headers in the request.
46
+ if (headers) {
47
+ if (headers.traceid) { requestAPI.set('X-Amzn-Trace-Id', headers.traceid); }
48
+ if (headers.token) { requestAPI.set('Authorization', headers.token.access_token); }
49
+ }
50
+
51
+ requestAPI
52
+ .agent(keepaliveAgent)
53
+ .then(function (res) { resolve(res); })
54
+ .catch(function (err) { reject(err); });
55
+ });
56
+ }
57
+
58
+ /**
59
+ * Sends an HTTP POST request to the specified URL with a JSON body and optional headers.
60
+ *
61
+ * @param {string} url - The endpoint to send the request to.
62
+ * @param {Object} options.params - Payload to be sent in the request body.
63
+ * @param {Object} options.headers - Optional headers including traceid and token.
64
+ */
65
+ function postRequest(url, options) {
66
+ var params = options.params, headers = options.headers;
67
+
68
+ return new Promise(function (resolve, reject) {
69
+ //Setup request with URL and Params
70
+ var requestAPI = Request.post(url)
71
+ .set('Content-Type', 'application/json')
72
+ .set('Accept', 'application/json')
73
+ .send(params);
74
+
75
+ // Setting headers in the request.
76
+ if (headers) {
77
+ if (headers.traceid) { requestAPI.set('X-Amzn-Trace-Id', headers.traceid); }
78
+ if (headers.token) { requestAPI.set('Authorization', headers.token.access_token); }
79
+ }
80
+
81
+ requestAPI
82
+ .agent(keepaliveAgent)
83
+ .then(function (res) { resolve(res); })
84
+ .catch(function (err) { reject(err); });
85
+ });
86
+ }
87
+
88
+ /**
89
+ * Sends an HTTP PUT request to the specified URL with a JSON body and optional headers.
90
+ *
91
+ * @param {string} url - The endpoint to send the request to.
92
+ * @param {Object} options.params - Payload to be sent in the request body.
93
+ * @param {Object} options.headers - Optional headers including traceid and token.
94
+ */
95
+ function putRequest(url, options) {
96
+ var params = options.params, headers = options.headers;
97
+
98
+ return new Promise(function (resolve, reject) {
99
+ //Setup request with URL and Params
100
+ var requestAPI = Request.put(url)
101
+ .set('Content-Type', 'application/json')
102
+ .set('Accept', 'application/json')
103
+ .send(params);
104
+
105
+ // Setting headers in the request.
106
+ if (headers) {
107
+ if (headers.traceid) { requestAPI.set('X-Amzn-Trace-Id', headers.traceid); }
108
+ if (headers.token) { requestAPI.set('Authorization', headers.token.access_token); }
109
+ }
110
+
111
+ requestAPI
112
+ .agent(keepaliveAgent)
113
+ .then(function (res) { resolve(res); })
114
+ .catch(function (err) { reject(err); });
115
+ });
116
+ }
117
+
118
+ /**
119
+ * Sends an HTTP DELETE request to the specified URL with optional payload and headers.
120
+ *
121
+ * @param {string} url - The endpoint to send the request to.
122
+ * @param {Object} options.params - Payload to be sent in the request body (optional).
123
+ * @param {Object} options.headers - Optional headers including traceid and token.
124
+ */
125
+ function deleteRequest(url, options) {
126
+ var params = options.params, headers = options.headers;
127
+
128
+ return new Promise(function (resolve, reject) {
129
+ //Setup request with URL and Params
130
+ var requestAPI = Request.delete(url)
131
+ .set('Content-Type', 'application/json')
132
+ .set('Accept', 'application/json')
133
+ .send(params);
134
+
135
+
136
+ // Setting headers in the request.
137
+ if (headers) {
138
+ if (headers.traceid) { requestAPI.set('X-Amzn-Trace-Id', headers.traceid); }
139
+ if (headers.token) { requestAPI.set('Authorization', headers.token.access_token); }
140
+ }
141
+
142
+ requestAPI
143
+ .agent(keepaliveAgent)
144
+ .then(function (res) { resolve(res); })
145
+ .catch(function (err) { reject(err); });
146
+ });
147
+ }
148
+
149
+ module.exports = {
150
+ get: getRequest,
151
+ post: postRequest,
152
+ put: putRequest,
153
+ delete: deleteRequest
154
+ };
@@ -17,85 +17,98 @@
17
17
  * is strictly forbidden unless prior written permission is obtained
18
18
  * from Compro Technologies Pvt. Ltd..
19
19
  ***************************************************************************/
20
+
20
21
  /***********************************************************
21
22
  * comproDLS SDK Validator Helper Module
22
23
  * This module contains validation helper functions for comproDLS SDK
23
24
  ************************************************************/
24
- var validator = require("validate.js");
25
+ var validator = require('validate.js');
25
26
  var errors = require('./errors');
26
27
  var DLSError = errors.DLSError;
27
28
 
28
-
29
- /****************************************************
30
- * Setting up Exports/Public functions
31
- *****************************************************/
32
29
  exports.validate = validate;
33
30
  exports.isAuthenticated = validateIsAuthenticated;
31
+ exports.isAuthenticatedV2 = validateIsAuthenticatedV2;
32
+
33
+ /**
34
+ * This function validates if the SDK instance is authenticated.
35
+ * It checks if the orgId and token are present.
36
+ * @param {String} orgId - Organization ID
37
+ * @param {Object} token - Token object { access_token: 'string' }
38
+ */
39
+ function validateIsAuthenticatedV2(orgId, token) {
40
+ if (orgId && token) { return; }
41
+
42
+ var errMsg = 'SDK Instance does not have valid orgid or token. ' +
43
+ 'Please authenticate using authWithCredentials or authWithToken method.';
44
+ var errObj = { message: errMsg, description: errMsg};
45
+ return new DLSError(errors.ERROR_TYPES.SDK_ERROR, errObj);
46
+ };
34
47
 
35
- /*********************************
36
- * Public Function definitions
37
- **********************************/
38
48
  function validate(options, constraints) {
39
- var err = {};
40
- var validation_errors = validator(options, constraints);
41
- if (validation_errors) {
42
- for (var validation_error in validation_errors) {
43
- err.message = err.description = validation_errors[validation_error][0];
44
- err = new DLSError(errors.ERROR_TYPES.SDK_ERROR, err);
45
- return err;
46
- }
47
- } else {
48
- return undefined;
49
+ var err = {};
50
+ var validation_errors = validator(options, constraints);
51
+ if (validation_errors) {
52
+ for (var validation_error in validation_errors) {
53
+ err.message = err.description = validation_errors[validation_error][0];
54
+ err = new DLSError(errors.ERROR_TYPES.SDK_ERROR, err);
55
+ return err;
49
56
  }
57
+ } else {
58
+ return undefined;
59
+ }
50
60
  };
51
61
 
62
+ /**
63
+ * This function is deprecated. Please use validateIsAuthenticatedV2 instead.
64
+ */
52
65
  function validateIsAuthenticated(orgId, token) {
53
- var validate_options = {
54
- 'organization': orgId,
55
- 'token': token
56
- };
66
+ var validate_options = {
67
+ 'organization': orgId,
68
+ 'token': token
69
+ };
57
70
 
58
- var validate_constraints = {
59
- "organization": {
60
- "presence": {
61
- "message" : "^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."
62
- }
63
- },
64
- "token": {
65
- "presence": {
66
- "message" : "^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method."
67
- }
68
- }
69
- };
71
+ var validate_constraints = {
72
+ 'organization': {
73
+ 'presence': {
74
+ 'message' : '^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method.'
75
+ }
76
+ },
77
+ 'token': {
78
+ 'presence': {
79
+ 'message' : '^SDK Instance does not have valid orgid or token. Please authenticate using authWithCredentials or authWithToken method.'
80
+ }
81
+ }
82
+ };
70
83
 
71
- return validate(validate_options, validate_constraints);
84
+ return validate(validate_options, validate_constraints);
72
85
  };
73
86
 
74
87
  /*********************************
75
88
  * Private Function definitions
76
89
  **********************************/
77
90
  validator.validators.isString = function(value, options) {
78
- if (!validator.isString(value)) {
79
- return options.message || "is not a valid string";
80
- }
91
+ if (!validator.isString(value)) {
92
+ return options.message || 'is not a valid string';
93
+ }
81
94
  };
82
95
 
83
96
  validator.validators.isObject = function(value, options) {
84
- if (!validator.isObject(value)) {
85
- return options.message || "is not a valid object";
86
- }
97
+ if (!validator.isObject(value)) {
98
+ return options.message || 'is not a valid object';
99
+ }
87
100
  };
88
101
 
89
102
  validator.validators.contains = function(value, options) {
90
- if (validator.isArray(options)) {
91
- for (var key in options) {
92
- if (!value || !value.hasOwnProperty(options[key])) {
93
- return options.message || "does not contain " + options[key];
94
- }
95
- }
96
- } else if (validator.isString(options)) {
97
- if (!value || !value.hasOwnProperty(options)) {
98
- return options.message || "does not contain " + options;
99
- }
103
+ if (validator.isArray(options)) {
104
+ for (var key in options) {
105
+ if (!value || !value.hasOwnProperty(options[key])) {
106
+ return options.message || 'does not contain ' + options[key];
107
+ }
108
+ }
109
+ } else if (validator.isString(options)) {
110
+ if (!value || !value.hasOwnProperty(options)) {
111
+ return options.message || 'does not contain ' + options;
100
112
  }
101
- };
113
+ }
114
+ };