// Time creates a schema.Conv object for parsing timestamps. Unlike the // other functions, Time receives a `layout` parameter which defines the // time.Time layout to use for parsing. func Time(layout, key string, opts ...schema.SchemaOption) schema.Conv { return schema.SetOptions(schema.Conv{ Key: key, Func: func(key string, data map[string]interface{}) (interface{}, error) { str, err := getString(key, data) if err != nil { return false, err } value, err := time.Parse(layout, str) if err != nil { return 0, fmt.Errorf("Error converting param to time.Time: %s. Original: %s", key, str) } return common.Time(value), nil }, }, opts) }
// Time creates a Conv object for converting Time objects. func Time(key string, opts ...schema.SchemaOption) schema.Conv { return schema.SetOptions(schema.Conv{Key: key, Func: toTime}, opts) }
// Int creates a Conv object for converting integers. Acceptable input // types are int64, int, and float64. func Int(key string, opts ...schema.SchemaOption) schema.Conv { return schema.SetOptions(schema.Conv{Key: key, Func: toInteger}, opts) }
// Bool creates a Conv object for converting booleans. func Bool(key string, opts ...schema.SchemaOption) schema.Conv { return schema.SetOptions(schema.Conv{Key: key, Func: toBool}, opts) }
// Str creates a schema.Conv object for converting strings. func Str(key string, opts ...schema.SchemaOption) schema.Conv { return schema.SetOptions(schema.Conv{Key: key, Func: toStr}, opts) }
// Float creates a Conv object for parsing floats func Float(key string, opts ...schema.SchemaOption) schema.Conv { return schema.SetOptions(schema.Conv{Key: key, Func: toFloat}, opts) }