coerce to schema
338177
function validated(invalid){
            if (invalid) { return callback(invalid) }
            if(options.coerce){crudUtils.coerceData(options,coerced())}
            else{coerced(null,options.data)}
        }
366105
def coerce(cls, key, value):
        """"""
        if value is None:
            return value
        if isinstance(value, cls):
            return value
        if isinstance(value, dict):
            return NestedMutableDict.coerce(key, value)
        if isinstance(value, list):
            return NestedMutableList.coerce(key, value)
        return super(cls).coerce(key, value)
320943
def _compile_literal(self, schema):
        
        # Prepare self
        self.compiled_type = const.COMPILED_TYPE.LITERAL
        self.name = get_literal_name(schema)

        # Error partials
        schema_type = type(schema)
        err_type  = self.Invalid(_(u'Wrong value type'), get_type_name(schema_type))
        err_value = self.Invalid(_(u'Invalid value'), self.name)

        # Matcher
        if self.matcher:
            def match_literal(v):
                return type(v) == schema_type and v == schema, v
            return match_literal

        # Validator
        def validate_literal(v):
            # Type check
            if type(v) != schema_type:
                # expected=<type>, provided=<type>
                raise err_type(get_type_name(type(v)))
            # Equality check
            if v != schema:
                # expected=<value>, provided=<value>
                raise err_value(get_literal_name(v))
            # Fine
            return v
        return validate_literal
122876
def _filter_schemas(schemas, schema_tables, exclude_table_columns):
    """"""
    return [_filter_schema(s, schema_tables, exclude_table_columns)
            for s in schemas]
264910
def coerce(cls, key, value):
        """"""
        self = MutationDict((k,MutationObj.coerce(key, v)) for (k, v) in value.items())
        self._key = key
        return self
1325370
function (args, done) {
      var q = _.clone(args.q)
      var qent = args.qent
      q.limit$ = 1
      var qs = schemastm(qent)

      self.connection.all(qs.text, function (err, results) {
        if (err) {
          return done(err)
        }
        var schema = {}
        results.forEach(function (row) {
          schema[row.name] = row.type.toLowerCase()
        })

        var query = selectstm(qent, q)

        self.connection.get(query.text, query.values, function (err, row) {
          if (err) {
            return done(err)
          }
          if (row) {
            var fent = makeent(qent, row, schema)
            seneca.log.debug('load', q, fent, desc)
            return done(null, fent)
          }
          return done(null, null)
        })
      })
    }
530123
def coerce(cls, key, value):
        """"""

        if not isinstance(value, MutableDict):
            if isinstance(value, dict):
                return MutableDict(value)
            elif isinstance(value, six.string_types):
                # Assume JSON string
                if value:
                    return MutableDict(simplejson.loads(value, use_decimal=True))
                else:
                    return MutableDict()  # Empty value is an empty dict

            # this call will raise ValueError
            return Mutable.coerce(key, value)
        else:
            return value
1224964
def from_schema(cls, schema, *args, **kwargs):
        

        return cls(schema.get(u"id", u""), schema, *args, **kwargs)
219902
def attach_schema(self, schem):
    """"""
    self.tuple_schema = schema.AndSchema.make(self.tuple_schema, schem)
848927
def dump(self, obj, context=None):
        """"""
        return self.schema_class(context=context).dump(obj).data
675883
def Coerce(type, message="Not a valid {} value"):
    
    @wraps(Coerce)
    def built(value):
        try:
            return type(value)
        except (TypeError, ValueError) as e:
            raise Error(message.format(type.__name__))
    return built
338135
def coerce(cls, key, value):
        """"""
        if not isinstance(value, MutationDict):
            if isinstance(value, dict):
                return MutationDict(value)

            # this call will raise ValueError
            return Mutable.coerce(key, value)
        else:
            return value
199696
function coerceAll (obj) {
  var type = Array.isArray(obj) ? 'array' : typeof obj;
  var i;
  var n;

  switch (type) {
    case 'string':
      return coerce(obj);
    case 'object':
      if (obj) {
        var props = Object.keys(obj);
        for (i = 0, n = props.length; i < n; i++) {
          var key = props[i];
          obj[key] = coerceAll(obj[key]);
        }
      }
      break;
    case 'array':
      for (i = 0, n = obj.length; i < n; i++) {
        coerceAll(obj[i]);
      }
      break;
  }

  return obj;
}
758348
def load_schema(schema):
    
    with repo.Repo.db:
        repo.Repo.db.executescript(schema)
535350
function wrapper(node, schema) {

    // NODES['*'] = xtend(NODES['*'], schema.NODES['*']);
    // delete schema.NODES;

    var ctx = {type: 'root', children: []}
    var replace

    if (!node || typeof node !== 'object' || !node.type) {
        return ctx
    }

    replace = one(xtend(defaults, schema || {}), node, [])

    if (!replace) {
        return ctx
    }

    if ('length' in replace) {
        if (replace.length === 1) {
            return replace[0]
        }

        ctx.children = replace

        return ctx
    }

    return replace
}
316615
def to_schema(self):
        """"""
        schema = super().to_schema()
        if self.disabled is not None:
            schema['disabled'] = self.disabled
        if self.collapsed is not None:
            schema['collapsed'] = self.collapsed

        group = []
        for field in self.fields.values():
            group.append(field.to_schema())
        schema['group'] = group

        return schema
1198797
function dict(schema, defaults, options) {
  if (kindOf(schema) !== 'array' || schema.length !== 2) {
    if (process.env.NODE_ENV !== 'production') {
      throw new Error(
        `Dict structs must be defined as an array with two elements, but you passed: ${schema}`
      )
    } else {
      throw new Error(`Invalid schema: ${schema}`)
    }
  }

  const obj = scalar('object', undefined, options)
  const keys = any(schema[0], undefined, options)
  const values = any(schema[1], undefined, options)
  const name = 'dict'
  const type = `dict<${keys.type},${values.type}>`
  const validate = value => {
    const resolved = resolveDefaults(defaults)
    value = resolved ? { ...resolved, ...value } : value
    const [error] = obj.validate(value)

    if (error) {
      error.type = type
      return [error]
    }

    const ret = {}
    const errors = []

    for (let k in value) {
      const v = value[k]
      const [e, r] = keys.validate(k)

      if (e) {
        const allE = e.errors || [e]
        allE.forEach(singleE => {
          singleE.path = [k].concat(singleE.path)
          singleE.data = value
          errors.push(singleE)
        })
        continue
      }

      k = r
      const [e2, r2] = values.validate(v)

      if (e2) {
        const allE2 = e2.errors || [e2]
        allE2.forEach(singleE => {
          singleE.path = [k].concat(singleE.path)
          singleE.data = value
          errors.push(singleE)
        })
        continue
      }

      ret[k] = r2
    }

    if (errors.length) {
      const first = errors[0]
      first.errors = errors
      return [first]
    }

    return [undefined, ret]
  }

  return new Kind(name, type, validate)
}