Create a joi object that can validate a `set` for Cassandra.

@param {Joi} type - used for validating the values of the set
@returns {Joi} - the validator
979953
function (type) {
    var meta = findMeta(type);
    var set = joi.array().sparse(false).unique().items(type);
    return joi.alternatives().meta({
      cql: true,
      type: 'set',
      setType: meta.type,
      serialize: convertArray(meta.serialize),
      deserialize: convertArray(meta.deserialize)
    }).try(set, joi.object().keys({
      add: set,
      remove: set
    }).or('add', 'remove').unknown(false));
  }
1163629
function(type){
            type = this.string(type);
            if(types.indexOf(type.toLowerCase()) < 0){
                throw new TypeError('a type in [' + types.join(', ') + '] is expected, but ' + type + ' given');
            }
            return type.toLowerCase();
        }
965591
function types () {
        var pub = {};

        var i;
        var keys = Object.keys(revalidator.validate.types);
        var length = keys.length;

        for (i = 0; i < length; i++) {
            pub[keys[i]] = getValidationFunctionForTypesByKey(keys[i]);
        }

        return pub;
    }
1030398
function(value, type) {
        var result = value;

        if (type === 'string') {
            result = String(value);
        } else if (type === 'number') {
            result = Number(value);
        } else if (type === 'boolean') {
            result = Boolean(value);
        }

        return result;
    }
707370
function Types() {
 
  var self = this
    , types = {};

  this.register = function (typeInfo) {

    if (!typeInfo) { throw new Error("Type information is required"); }

    var type = typeInfo.type;

    if (!typeInfo.name) {
      throw new Error("Type name is missing");
    }
    if (!typeInfo.version) {
      throw new Error("Type version is missing");
    }

    typeInfo.create = typeInfo.create || function create(values) {
      var instance = {
        "type": typeInfo.name,
        "version": typeInfo.version
      };

      if (type) {
        Object.keys(type).forEach(function (name) {
          instance[name] = type[name];
        });
      }
      if (values) {
        Object.keys(values).forEach(function (name) {
          instance[name] = values[name];
        });
      }

      return instance;
    };

    typeInfo.validate = (function (validation) {
      return function validate(instance) {
        var results = [];
        if (!instance) {
          results.push("Instance of type '" + typeInfo.name + "' can not be null or undefined");
        } else {
          if (!instance.type) {
            results.push("Instance of type '" + typeInfo.name + "' must have a type property");
          } else if (instance.type !== typeInfo.name) {
            results.push("Instance is of type '" + instance.type + "' and not of '" + typeInfo.name + "'");
          }
          if (!instance.version) {
            results.push("Instance of type '" + typeInfo.name + "' does not have a version");
          } else if (instance.version !== typeInfo.version) {
            results.push("Instance is version '" + instance.type + "' and not version '" + typeInfo.name + "'");
          }
          if (validation) {
            results = results.concat(validation(instance));
          }
        }
        return results;
      };
    }(typeInfo.validate));

    if (types[typeInfo.name] && types[typeInfo.name][typeInfo.version]) {
      throw new Error("Type '" + typeInfo.name + "' with version '" +
        typeInfo.version + "' is already registered.");
    }

    types[typeInfo.name] = types[typeInfo.name] || {};
    types[typeInfo.name][typeInfo.version] = typeInfo;

    if (typeInfo.version > (types[typeInfo.name].latestVersion || -1)) {
      types[typeInfo.name].latestVersion = typeInfo.version;
    }
  };

  this.validate = function (item) {
    return item && item.type && item.version &&
      types[item.type] && types[item.type][item.version]
      && types[item.type][item.version].validate(item);
  };

  this.get = function (name, version) {

    if (typeof name !== 'string' && typeof version !== 'number') {
      if (typeof name === 'object' && name.name && name.version) {
        version = name.version;
        name = name.name;
      } else if (typeof name === 'object' && name.type && name.version) {
        version = name.version;
        name = name.type;
      }
    }

    if (!types[name]) {
      throw new Error("Type '" + name + "' is not registered.");
    }
    version = version || types[name].latestVersion;
    if (!types[name][version]) {
      throw new Error("Type '" + name + "' with version '" +
        version + "' is not registered.");
    }
    return types[name][version];
  };

  this.getAll = function () {
    return Object.keys(types).map(function (name) {
      return types[name];
    });
  };

  this.create = function (name, version, values) {

    if (typeof name === 'string' && typeof version === 'object' && !values) {
      values = version;
      version = undefined;
    } else if (typeof name !== 'string' && typeof version !== 'number') {
      if (typeof name === 'object' && (name.type || name.name) && name.version) {
        values = name;
        version = name.version;
        name = name.type || name.name;
      }
    }

    return self.get(name, version).create(values);
  };
}
365996
function validate (errObj, request, schema, location, allowUnknown, context) {
  if (!request || !schema) return;

  var joiOptions = {
    context: context || request,
    allowUnknown: allowUnknown,
    abortEarly: false
  };

  Joi.validate(request, schema, joiOptions, function (errors, value) {
    if (!errors || errors.details.length === 0) {
      assignIn(request, value); // joi responses are parsed into JSON
      return;
    }
    errors.details.forEach(function (error) {
      var errorExists = find(errObj, function (item) {
        if (item && item.field === error.path && item.location === location) {
          item.messages.push(error.message);
          item.types.push(error.type);
          return item;
        }
        return;
      });

      if (!errorExists) {
        errObj.push({
          field: error.path,
          location: location,
          messages: [error.message],
          types: [error.type]
        });
      }

    });
  });
}
26602
function(type) {
    if (typeof XMLHttpRequest == 'undefined') {
      return false;
    }
    var xhr = new XMLHttpRequest();
    xhr.open('get', '/', true);
    try {
      xhr.responseType = type;
    } catch(error) {
      return false;
    }
    return 'response' in xhr && xhr.responseType == type;
  }
408362
function(type) {
			var result = this.child();
			var me = this.spirit.element;
			if (type) {
				new gui.Crawler().descend(me, {
					handleSpirit: function(spirit) {
						if (spirit instanceof type) {
							if (spirit.element !== me) {
								result = spirit;
								return gui.Crawler.STOP;
							}
						}
					}
				});
			}
			return result;
		}
330174
function validate (type, value) {
  const { t } = readType(type)
  if (value === undefined || value === null) return { require: true }

  switch (t) {
    case SOPHIA_TYPES.int:
      return isNaN(value) || ['boolean'].includes(typeof value)
    case SOPHIA_TYPES.bool:
      return typeof value !== 'boolean'
    case SOPHIA_TYPES.address:
      return !(value[2] === '_' && ['ak', 'ct'].includes(value.slice(0, 2)))
    default:
      return false
  }
}
311339
function declaration(obj) {
	const
		{error, value} = joi.validate(obj, declarationSchema);

	if (error) {
		throw new TypeError(`Invalid declaration object: ${error.message}`);
	}

	return value;
}
430214
public int createIds(String type) {

		List<String> tables = getMissing(type);

		for (String tableName : tables) {
			getOrCreate(tableName);
		}

		return tables.size();
	}
2097
function validate (data, schema) {
  if (!data || !schema) {
    throw new Error('Trying to validate without passing data and schema')
  }
  return Joi.validate(data, schema)
}
970419
public static JcPrimitive fromType(Class<?> type, String name) {
		// TODO what about dates and arrays
		if (type.equals(String.class))
			return new JcString(name);
		else if (type.equals(Number.class))
			return new JcNumber(name);
		else if (type.equals(Boolean.class))
			return new JcBoolean(name);
		return null;
	}
740187
function(type, key, ref, owner, context, props) {
  // Built-in properties that belong on the element
  this.type = type;
  this.key = key;
  this.ref = ref;

  // Record the component responsible for creating this element.
  this._owner = owner;

  // TODO: Deprecate withContext, and then the context becomes accessible
  // through the owner.
  this._context = context;

  if ("production" !== process.env.NODE_ENV) {
    // The validation flag and props are currently mutative. We put them on
    // an external backing store so that we can freeze the whole object.
    // This can be replaced with a WeakMap once they are implemented in
    // commonly used development environments.
    this._store = {props: props, originalProps: assign({}, props)};

    // To make comparing ReactElements easier for testing purposes, we make
    // the validation flag non-enumerable (where possible, which should
    // include every environment we run tests in), so the test framework
    // ignores it.
    try {
      Object.defineProperty(this._store, 'validated', {
        configurable: false,
        enumerable: false,
        writable: true
      });
    } catch (x) {
    }
    this._store.validated = false;

    // We're not allowed to set props directly on the object so we early
    // return and rely on the prototype membrane to forward to the backing
    // store.
    if (useMutationMembrane) {
      Object.freeze(this);
      return;
    }
  }

  this.props = props;
}
235033
function(type) {
			var result = this.parent();
			if (type) {
				result = null;
				new gui.Crawler().ascend(this.spirit.element, {
					handleSpirit: function(spirit) {
						if (spirit instanceof type) {
							result = spirit;
							return gui.Crawler.STOP;
						}
					}
				});
			}
			return result;
		}
1210955
Node createAwait(JSType jsType, Node value) {
    Node result = IR.await(value);
    if (isAddingTypes()) {
      result.setJSType(checkNotNull(jsType));
    }
    return result;
  }
1166034
public T orElseCreate(Class<? extends T> type) {
		Assert.notNull(type, "Type must not be null");
		return (this.value != null) ? this.value : BeanUtils.instantiateClass(type);
	}