const demo = { title: true, name: { type: 'object', schema: { first: true, second: true, last: true } } }
427597
function persistObject(target, schema) {
    var model = createModel(schema);
    serializr_1.setDefaultModelSchema(target, model);
    return target;
}
811231
function(instanceObject) {
      if(!instanceObject || !instanceObject["$schema"]) {
         throw new Error("Invalid json schema instance object. Object must have a '$schema' property.");
      }
      
      var formDef = this.schemaToInputEx(instanceObject["$schema"]);
      
      // Set the default value of each property to the instance value
      for(var i = 0 ; i < formDef.fields.length ; i++) {
         var fieldName = formDef.fields[i].name;
         formDef.fields[i].value = instanceObject[fieldName];
      }
      
      return formDef;
   }
726584
async function validate(descriptor) {
  const {valid, errors} = await Schema.load(descriptor)
  return {valid, errors}
}
159205
function() {
    var obj = {};
    for (var type in this.prefs_) {
      if (this.prefs_.hasOwnProperty(type)) {
        obj[type] = this.prefs_[type].name;
      }
    }
    return obj;
  }
966067
function generateConfigsFromSchema(schema) {
    const configSet = new RuleConfigSet();

    if (Array.isArray(schema)) {
        for (const opt of schema) {
            if (opt.enum) {
                configSet.addEnums(opt.enum);
            } else if (opt.type && opt.type === "object") {
                if (!configSet.addObject(opt)) {
                    break;
                }

            // TODO (IanVS): support oneOf
            } else {

                // If we don't know how to fill in this option, don't fill in any of the following options.
                break;
            }
        }
    }
    configSet.addErrorSeverity();
    return configSet.ruleConfigs;
}
589305
function(e) {
    const doclets = e.doclets;
    for (let i = 0, ii = doclets.length; i < ii; ++i) {
      const doclet = doclets[i];
      if (doclet.params) {
        const params = doclet.params;
        for (let j = 0, jj = params.length; j < jj; ++j) {
          const param = params[j];
          if (param.type && param.type.names) {
            const type = param.type.names[0];
            if (type in properties) {
              param.type.names[0] = type;
              params.push.apply(params, properties[type].map(p => {
                const property = Object.assign({}, p);
                property.name = `${param.name}.${property.name}`;
                return property;
              }));
            }
          }
        }
      }
    }
  }
1166790
function guessObjectType(obj, shortname=false) {
  var type
  if (typeof obj === "string" && obj) {
    if (obj in objectTypeUris) {
      // given by URI
      type = objectTypeUris[obj]
    } else {
      // given by name
      obj = obj.toLowerCase().replace(/s$/,"")
      type = Object.keys(objectTypes).find(name => {
        const lowercase = name.toLowerCase()
        if (lowercase === obj || lowercase === "concept" + obj) {
          return true
        }
      })
    }
  } else if (typeof obj === "object") {
    if (obj.type) {
      let types = Array.isArray(obj.type) ? obj.type : [obj.type]
      for (let uri of types) {
        if (uri in objectTypeUris) {
          type = objectTypeUris[uri]
          break
        }
      }
    }
  }
  return (shortname && type) ? type.toLowerCase().replace(/^concept(.+)/, "$1") : type
}
226429
def merge_schema(first, second):
    
    if not (type(first) == type(second) == dict):
        raise ValueError("Argument is not a schema")

    if not (first.get('type') == second.get('type') == 'object'):
        raise NotImplementedError("Unsupported root type")

    return merge_objects(first, second)
1018256
function(def) {
    def = def ? def : _.result(this, 'definition');

    return _.reduce(def, function(schema, attr, key) {
      if (attr.type === 'object') {
        schema[key] = this.schema(attr.fields || {});
      } else if (attr.type === 'array') {
        if (attr.value_type === 'object') {
          schema[key] = [this.schema(attr.fields || {})];
        } else if (attr.value_type) {
          schema[key] = [attr.value_type];
        } else {
          schema[key] = [];
        }
      } else {
        schema[key] = attr.type;
      }
      return schema;
    }.bind(this), {});
  }
34656
function(object) {
      var str = '';

      var first = true;

      for (var key in object) {
        if (Object.prototype.hasOwnProperty.call(object, key)) {
          var val = object[key];

          str += first ? '?' : '&';
          str += key;
          str += '=';
          str += val;

          first = false;
        }
      }

      return str;
    }
1319092
function getObjectSchema(object) {
  var outputObject = {};

  if (isObjectObject(object)) {
    Object.keys(object).forEach(function(key) {
      outputObject[key] = isObjectObject(object[key]) ? getObjectSchema(object[key]) : '';
    });
  }

  return outputObject;
}
1343991
function (schema, process) {
		var that = this;

		if (!(schema instanceof Schema)) {
			throw new Error('first argument must be instance of Schema');
		}

		if (process) {
			var r = process.call(this, schema);

			if (r != null && !r) {
				return this;
			}
		}

		_.each(schema.fields, function (fieldSchema, fieldName) {
			that.field(fieldName).like(fieldSchema, process);
		});

		if (process) {
			return this;
		}

		_.each(schema, function (value, key) {
			if (/^(_.*|fields)$/.test(key)) {
				return;
			}

			that[key] = _.cloneDeep(value);
		});

		return this;
	}
1160538
function processProps (instance) {
  let props
  if (isLegacy && (props = instance._props)) {
    // 1.x
    return Object.keys(props).map(key => {
      const prop = props[key]
      const options = prop.options
      return {
        type: 'props',
        key: prop.path,
        value: instance[prop.path],
        meta: options ? {
          type: options.type ? getPropType(options.type) : 'any',
          required: !!options.required,
          mode: propModes[prop.mode]
        } : {}
      }
    })
  } else if ((props = instance.$options.props)) {
    // 2.0
    const propsData = []
    for (let key in props) {
      const prop = props[key]
      key = camelize(key)
      propsData.push({
        type: 'props',
        key,
        value: instance[key],
        meta: prop ? {
          type: prop.type ? getPropType(prop.type) : 'any',
          required: !!prop.required
        } : {
          type: 'invalid'
        },
        editable: SharedData.editableProps
      })
    }
    return propsData
  } else {
    return []
  }
}
75193
function autoValidate(object) {
  const seq = (object) ? object.seq : undefined;
  const action = (object) ? object.action : undefined;

  const schema = identifySchema(object)

  if (schema) {
    const {error, value} = validate(object, schema);

    if (error) {
      return { isValid: false, seq, action, error };
    } else {
      return { isValid: true, seq, action, value };
    }
  } else {
    return { isValid: false, seq, action,
      error: new Error('No matching schema found.') };
  }
}
443646
function checkProp(value, schema, path,i){

         var l;
         path += path ? typeof i == 'number' ? '[' + i + ']' : typeof i == 'undefined' ? '' : '.' + i : i;
         function addError(message){
           errors.push({property:path,message:message});
         }

         if((typeof schema != 'object' || schema instanceof Array) &&
             (path || typeof schema != 'function') && !(schema && getType(schema))){
             if(typeof schema == 'function'){
                 if(!(value instanceof schema)){
                     addError("is not an instance of the class/constructor " + schema.name);
                 }
             }else if(schema){
                 addError("Invalid schema/property definition " + schema);
             }
             return null;
         }
         if(_changing && schema.readonly){
             addError("is a readonly field, it can not be changed");
         }
         if(schema['extends']){ // if it extends another schema, it must pass that schema as well
             checkProp(value,schema['extends'],path,i);
         }
         // validate a value against a type definition
         function checkType(type,value){
             if(type){
                 if(typeof type == 'string' && type != 'any' &&
                         (type == 'null' ? value !== null : typeof value != type) &&
                         !(value instanceof Array && type == 'array') &&
                         !(value instanceof Date && type == 'date') &&
                         !(type == 'integer' && value%1===0)){
                     return [{property:path,message:(typeof value) + " value found, but a " + type + " is required"}];
                 }
                 if(type instanceof Array){
                     var unionErrors=[];
                     for(var j = 0; j < type.length; j++){ // a union type
                         if(!(unionErrors=checkType(type[j],value)).length){
                             break;
                         }
                     }
                     if(unionErrors.length){
                         return unionErrors;
                     }
                 }else if(typeof type == 'object'){
                     var priorErrors = errors;
                     errors = [];
                     checkProp(value,type,path);
                     var theseErrors = errors;
                     errors = priorErrors;
                     return theseErrors;
                 }
             }
             return [];
         }
         if(value === undefined){
             if(schema.required){
                 addError("is missing and it is required");
             }
         } else{
             errors = errors.concat(checkType(getType(schema),value));
             if(schema.disallow && !checkType(schema.disallow,value).length){
                 addError(" disallowed value was matched");
             }
             if(value !== null){
                 if(value instanceof Array){
                     if(schema.items){
                         var itemsIsArray = schema.items instanceof Array;
                         var propDef = schema.items;
                         for (i = 0, l = value.length; i < l; i += 1) {
                             if (itemsIsArray)
                                 propDef = schema.items[i];
                             if (options.coerce)
                                 value[i] = options.coerce(value[i], propDef);
                             errors.concat(checkProp(value[i],propDef,path,i));
                         }
                     }
                     if(schema.minItems && value.length < schema.minItems){
                         addError("There must be a minimum of " + schema.minItems + " in the array");
                     }
                     if(schema.maxItems && value.length > schema.maxItems){
                         addError("There must be a maximum of " + schema.maxItems + " in the array");
                     }
                 }else if(schema.properties || schema.additionalProperties){
                     errors.concat(checkObj(value, schema.properties, path, schema.additionalProperties));
                 }
                 if(schema.pattern && typeof value == 'string' && !value.match(schema.pattern)){
                     addError("does not match the regex pattern " + schema.pattern);
                 }
                 if(schema.maxLength && typeof value == 'string' && value.length > schema.maxLength){
                     addError("may only be " + schema.maxLength + " characters long");
                 }
                 if(schema.minLength && typeof value == 'string' && value.length < schema.minLength){
                     addError("must be at least " + schema.minLength + " characters long");
                 }
                 if(typeof schema.minimum !== undefined && typeof value == typeof schema.minimum &&
                         schema.minimum > value){
                     addError("must have a minimum value of " + schema.minimum);
                 }
                 if(typeof schema.maximum !== undefined && typeof value == typeof schema.maximum &&
                         schema.maximum < value){
                     addError("must have a maximum value of " + schema.maximum);
                 }
                 if(schema['enum']){
                     var enumer = schema['enum'];
                     l = enumer.length;
                     var found;
                     for(var j = 0; j < l; j++){
                         if(enumer[j]===value){
                             found=1;
                             break;
                         }
                     }
                     if(!found){
                         addError("does not have a value in the enumeration " + enumer.join(", "));
                     }
                 }
                 if(typeof schema.maxDecimal == 'number' &&
                     (value.toString().match(new RegExp("\\.[0-9]{" + (schema.maxDecimal + 1) + ",}")))){
                     addError("may only have " + schema.maxDecimal + " digits of decimal places");
                 }
             }
         }
         return null;
      }
658152
function inferTypeByKeyword(schema) {
  for (const keyword of objectKeywords) {
    if (keyword in schema) {
      return 'object'
    }
  }
  for (const keyword of arrayKeywords) {
    if (keyword in schema) {
      return 'array'
    }
  }
  return schema.type
}
397880
function (schema, models, modelsToIgnore, modelPropertyMacro) {
    // Resolve the schema (Handle nested schemas)
    schema = resolveSchema(schema);

    if(typeof modelPropertyMacro !== 'function') {
      modelPropertyMacro = function(prop){
        return (prop || {}).default;
      };
    }

    modelsToIgnore= modelsToIgnore || {};

    var type = schema.type || 'object';
    var format = schema.format;
    var model;
    var output;

    if (!_.isUndefined(schema.example)) {
      output = schema.example;
    } else if (_.isUndefined(schema.items) && _.isArray(schema.enum)) {
      output = schema.enum[0];
    }

    if (_.isUndefined(output)) {
      if (schema.$ref) {
        model = models[simpleRef(schema.$ref)];

        if (!_.isUndefined(model)) {
          if (_.isUndefined(modelsToIgnore[model.name])) {
            modelsToIgnore[model.name] = model;
            output = schemaToJSON(model.definition, models, modelsToIgnore, modelPropertyMacro);
            delete modelsToIgnore[model.name];
          } else {
            if (model.type === 'array') {
              output = [];
            } else {
              output = {};
            }
          }
        }
      } else if (!_.isUndefined(schema.default)) {
        output = schema.default;
      } else if (type === 'string') {
        if (format === 'date-time') {
          output = new Date().toISOString();
        } else if (format === 'date') {
          output = new Date().toISOString().split('T')[0];
        } else {
          output = 'string';
        }
      } else if (type === 'integer') {
        output = 0;
      } else if (type === 'number') {
        output = 0.0;
      } else if (type === 'boolean') {
        output = true;
      } else if (type === 'object') {
        output = {};

        _.forEach(schema.properties, function (property, name) {
          var cProperty = _.cloneDeep(property);

          // Allow macro to set the default value
          cProperty.default = modelPropertyMacro(property);

          output[name] = schemaToJSON(cProperty, models, modelsToIgnore, modelPropertyMacro);
        });
      } else if (type === 'array') {
        output = [];

        if (_.isArray(schema.items)) {
          _.forEach(schema.items, function (item) {
            output.push(schemaToJSON(item, models, modelsToIgnore, modelPropertyMacro));
          });
        } else if (_.isPlainObject(schema.items)) {
          output.push(schemaToJSON(schema.items, models, modelsToIgnore, modelPropertyMacro));
        } else if (_.isUndefined(schema.items)) {
          output.push({});
        } else {
          console.log('Array type\'s \'items\' property is not an array or an object, cannot process');
        }
      }
    }

    return output;
  }