Пример #1
0
 resolver.resolve(validMock, function (err, result) {
   st.equal(err, null, 'error should be undefined');
   st.ok(thing.isRegExp(result.regex), 'result should be a RegExp');
   st.ok(result.regex.test('testMe'), 'testMe is valid');
   st.notOk(result.regex.test('uhoh'), 'uhoh is invalid');
   st.end();
 });
Пример #2
0
	queryKeys.forEach(function (key) {
		var routeQueryValue = route.request.query[key];
		if (util.isRegExp(this.request.query[key])) {
			this.debug('4b. Testing', routeQueryValue, 'matches', this.request.query[key]);
			same = same && this.request.query[key].test(routeQueryValue);
			this.debug('4c. Result is', same);
		} else {
			// Not checking type because 1 and '1' are the same in this case
			this.debug('4b. Comparing', this.request.query[key], 'and', routeQueryValue);
			same = same && this.request.query[key] == routeQueryValue;
			this.debug('4c. Result is', same);
		}
	}.bind(this));
Пример #3
0
  definition: {
    validate (value) {
      if (isFunction(value)) {
        return true
      }

      throw new TypeError('not a function')
    }
  }
},

{
  name: ['regexp', RegExp],
  definition: {
    set (value) {
      if (isRegExp(value)) {
        return value
      }

      if (isString(value)) {
        return new RegExp(value)
      }

      throw new TypeError('not a regular expression')
    }
  }
},

{
  name: ['error', Error],
  definition: {