Documentation
¶
Index ¶
- func Serialize(src any) ([]byte, error)
- func ToString(vals interface{}) string
- type ArrayRule
- type BetweenRule
- type DateRule
- type EmailRule
- type EnumRule
- type FloatRule
- type IntRule
- type Item
- func (s Item) Any(def interface{}, atribs ...string) interface{}
- func (s Item) Array(atrib string) []interface{}
- func (s Item) ArrayInt(atribs ...string) []int
- func (s Item) ArrayInt64(atribs ...string) []int64
- func (s Item) ArrayJson(atribs ...string) []Json
- func (s Item) ArrayStr(atribs ...string) []string
- func (s Item) Bool(atribs ...string) bool
- func (s Item) Byte(atribs ...string) ([]byte, error)
- func (s Item) Delete(keys []string) bool
- func (s Item) Exist(key string) bool
- func (s Item) FromBase64(atribs ...string) string
- func (s Item) Get(key string) interface{}
- func (s Item) Int(atribs ...string) int
- func (s Item) Int64(atribs ...string) int64
- func (s *Item) IsEmpty() bool
- func (s Item) Json(atrib string) Json
- func (s Item) Num(atribs ...string) float64
- func (s Item) Set(key string, val interface{})
- func (s Item) Str(atribs ...string) string
- func (s Item) String(atribs ...string) string
- func (s Item) Time(atribs ...string) time.Time
- func (s Item) ToBase64(atribs ...string) string
- func (s Item) ToByte() ([]byte, error)
- func (s Item) ToJson() Json
- func (s Item) ToMap() map[string]interface{}
- func (s Item) ToString() string
- func (s *Item) ValAny(def interface{}, atribs ...string) interface{}
- func (s Item) ValArray(def []interface{}, atribs ...string) []interface{}
- func (s *Item) ValBool(def bool, atribs ...string) bool
- func (s *Item) ValInt(def int, atribs ...string) int
- func (s Item) ValInt64(def int64, atribs ...string) int64
- func (s *Item) ValJson(def Json, atribs ...string) Json
- func (s *Item) ValNum(def float64, atribs ...string) float64
- func (s *Item) ValStr(def string, atribs ...string) string
- func (s *Item) ValTime(def time.Time, atribs ...string) time.Time
- type Items
- func (s *Items) Add(item ...Json)
- func (s *Items) Any(idx int, def interface{}, atribs ...string) interface{}
- func (s Items) Array(idx int, atrib string) []interface{}
- func (s Items) ArrayInt(idx int, atribs ...string) []int
- func (s Items) ArrayInt64(idx int, atribs ...string) []int64
- func (s Items) ArrayJson(idx int, atribs ...string) []Json
- func (s Items) ArrayStr(idx int, atribs ...string) []string
- func (s Items) Bool(idx int, atribs ...string) bool
- func (s *Items) Delete(idx int, keys []string) bool
- func (s Items) Exist(idx int, key string) bool
- func (s Items) First() Json
- func (s Items) Get(idx int, key string) interface{}
- func (s Items) Int(idx int, atribs ...string) int
- func (s Items) Int64(idx int, atribs ...string) int64
- func (s Items) Json(idx int, atrib string) Json
- func (s Items) Num(idx int, atribs ...string) float64
- func (s *Items) Set(idx int, key string, val interface{})
- func (s Items) Str(dx int, atribs ...string) string
- func (s Items) String(idx int, atribs ...string) string
- func (s Items) Time(idx int, atribs ...string) time.Time
- func (s Items) ToByte() ([]byte, error)
- func (s Items) ToJson() Json
- func (s *Items) ToList(all, page, rows int) List
- func (s *Items) ToMap() map[string]interface{}
- func (s Items) ToString() string
- func (s *Items) ValAny(idx int, def any, atribs ...string) interface{}
- func (s *Items) ValArray(idx int, def []interface{}, atribs ...string) []interface{}
- func (s *Items) ValBool(idx int, def bool, atribs ...string) bool
- func (s *Items) ValInt(idx int, def int, atribs ...string) int
- func (s *Items) ValInt64(idx int64, def int64, atribs ...string) int64
- func (s *Items) ValJson(idx int, def Json, atribs ...string) Json
- func (s *Items) ValNum(idx int, def float64, atribs ...string) float64
- func (s *Items) ValStr(idx int, def string, atribs ...string) string
- func (s *Items) ValTime(idx int, def time.Time, atribs ...string) time.Time
- type Json
- func (s Json) Any(def interface{}, atribs ...string) interface{}
- func (s Json) Append(from Json) Json
- func (s Json) Array(atrib ...string) []interface{}
- func (s Json) ArrayInt(atribs ...string) []int
- func (s Json) ArrayInt64(atribs ...string) []int64
- func (s Json) ArrayJson(atribs ...string) []Json
- func (s Json) ArrayNumber(atribs ...string) []float64
- func (s Json) ArrayStr(atribs ...string) []string
- func (s Json) Bool(atribs ...string) bool
- func (s Json) Byte(atribs ...string) ([]byte, error)
- func (s Json) Clone() Json
- func (s Json) Compare(from Json) Json
- func (s Json) Delete(keys []string) bool
- func (s Json) Exist(key string) bool
- func (s Json) FromBase64(atribs ...string) string
- func (s Json) Get(keys ...string) (result interface{})
- func (s Json) Hidden(keys []string) Json
- func (s Json) Int(atribs ...string) int
- func (s Json) Int64(atribs ...string) int64
- func (s Json) IsChanged(from Json) bool
- func (s Json) IsEmpty() bool
- func (s Json) IsExist(key string) bool
- func (s Json) Json(atrib string) Json
- func (s Json) Maybe(rules ...Rule) error
- func (s Json) Num(atribs ...string) float64
- func (s Json) Remove(keys ...string)
- func (s Json) Require(rules ...Rule) error
- func (s *Json) Scan(src interface{}) error
- func (s *Json) ScanRows(rows *sql.Rows) error
- func (s Json) Select(keys []string) Json
- func (s Json) Set(key string, val interface{})
- func (j Json) SetNested(keys []string, value interface{})
- func (s Json) Str(atribs ...string) string
- func (s Json) String(atribs ...string) string
- func (s Json) Time(atribs ...string) time.Time
- func (s Json) ToBase64(atribs ...string) string
- func (s Json) ToByte() ([]byte, error)
- func (s Json) ToEscapeHTML() string
- func (s Json) ToMap() map[string]interface{}
- func (s Json) ToString() string
- func (s Json) Update(from Json)
- func (s Json) ValAny(def interface{}, atribs ...string) (result interface{})
- func (s Json) ValArray(def []interface{}, atribs ...string) []interface{}
- func (s Json) ValBool(def bool, atribs ...string) bool
- func (s Json) ValInt(def int, atribs ...string) int
- func (s Json) ValInt64(def int64, atribs ...string) int64
- func (s Json) ValJson(def Json, atribs ...string) Json
- func (s Json) ValNum(def float64, atribs ...string) float64
- func (s Json) ValStr(def string, atribs ...string) string
- func (s Json) ValTime(def time.Time, atribs ...string) time.Time
- type List
- type ObjectRule
- type PhoneRule
- type Rule
- type StringRule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ArrayRule ¶ added in v1.0.20
type ArrayRule struct {
// contains filtered or unexported fields
}
type BetweenRule ¶ added in v1.0.20
type BetweenRule struct {
// contains filtered or unexported fields
}
func Between ¶ added in v1.0.20
func Between(name string, min, max float64) *BetweenRule
* * Between * @param name string, min, max float64 * @return *BetweenRule *
func (*BetweenRule) Name ¶ added in v1.0.21
func (r *BetweenRule) Name() string
* * Name * @return string *
func (*BetweenRule) Validate ¶ added in v1.0.20
func (r *BetweenRule) Validate(j Json) error
* * Validate * @param j Json * @return error *
type DateRule ¶ added in v1.0.20
type DateRule struct {
// contains filtered or unexported fields
}
type EmailRule ¶ added in v1.0.20
type EmailRule struct {
// contains filtered or unexported fields
}
type EnumRule ¶ added in v1.0.20
type EnumRule struct {
// contains filtered or unexported fields
}
type FloatRule ¶ added in v1.0.20
type FloatRule struct {
// contains filtered or unexported fields
}
type IntRule ¶ added in v1.0.20
type IntRule struct {
// contains filtered or unexported fields
}
type Item ¶
func (Item) Any ¶
* * Any return any value of the key * @param def interface{}, atribs ...string * @return interface{} *
func (Item) ArrayInt64 ¶
* * ArrayInt64 * @param atribs ...string * @return []int64 *
func (Item) Byte ¶
* * Byte return the value of the key * @param atribs ...string * @return []byte *
func (Item) Exist ¶ added in v1.0.20
* * Exist return if the key exist * @param key string * @return bool *
func (Item) FromBase64 ¶ added in v1.0.12
* * FromBase64 return the value of the key * @param atribs ...string * @return []string *
func (Item) Int64 ¶
* * Int64 return the value of the key * @param atribs ...string * @return int64 *
func (*Item) IsEmpty ¶ added in v1.0.11
* * IsEmpty return true if the json is empty * @return bool *
func (Item) Set ¶
* * Set a value in the key * @param key string * @param val interface{} * @return bool *
func (Item) String ¶ added in v1.0.17
* * String return the value of the key * @param atribs ...string * @return string *
func (Item) Time ¶
* * Time return the value of the key * @param atribs ...string * @return time.Time *
func (Item) ToBase64 ¶ added in v1.0.12
* * ToBase64 return the value of the key * @param atribs ...string * @return []string *
func (Item) ToMap ¶ added in v0.1.17
* * ToMap convert a json to a map * @return map[string]interface{} *
func (*Item) ValAny ¶
* * ValAny return any value of the key * @param def interface{}, atribs ...string * @return interface{} *
func (Item) ValArray ¶
* * ValArray return []interface{} value of the key * @param def []interface{}, atribs ...string * @return []interface{} *
func (*Item) ValBool ¶
* * ValBool return bool value of the key * @param def bool, atribs ...string * @return bool *
func (*Item) ValInt ¶
* * ValInt return int value of the key * @param def int, atribs ...string * @return int *
func (Item) ValInt64 ¶
* * ValInt64 return int64 value of the key * @param def int64, atribs ...string * @return int64 *
func (*Item) ValJson ¶
* * ValJson return Json value of the key * @param def Json, atribs ...string * @return Json *
func (*Item) ValNum ¶
* * ValNum return float64 value of the key * @param def float64, atribs ...string * @return float64 *
type Items ¶
func (*Items) Any ¶
* * Any return the value of the key * @param idx int, def interface{}, atribs ...string * @return interface{} *
func (Items) Array ¶
* * Array return the value of the key * @param idx int, atrib string * @return []Json *
func (Items) ArrayInt64 ¶
* * ArrayInt64 * @param idx int, atribs ...string * @return []int64 *
func (Items) Bool ¶
* * Bool return the value of the key * @param idx int, atribs ...string * @return bool *
func (*Items) Delete ¶
* * Delete a value in the key * @param idx int, keys []string * @return bool *
func (Items) Exist ¶ added in v1.0.20
* * ExistKey return if the key exist * @param idx int, key string * @return bool *
func (Items) Int ¶
* * Int return the value of the key * @param idx int, atribs ...string * @return int *
func (Items) Int64 ¶
* * Int64 return the value of the key * @param idx int, atribs ...string * @return int64 *
func (Items) Json ¶
* * Json return the value of the key * @param idx int, atrib string * @return Json *
func (Items) Num ¶
* * Num return the value of the key * @param idx int, atribs ...string * @return float64 *
func (*Items) Set ¶
* * Set a value in the key * @param idx int, key string, val interface{} * @return bool *
func (Items) Str ¶
* * Str return the value of the key * @param idx int, atribs ...string * @return string *
func (Items) String ¶ added in v1.0.17
* * String return the value of the key * @param idx int, atribs ...string * @return string *
func (Items) Time ¶
* * Time return the value of the key * @param idx int, atribs ...string * @return time.Time *
func (*Items) ToList ¶
* * ToList return the value type List * @param all int, page int, rows int * @return List *
func (*Items) ToMap ¶ added in v0.1.17
* * ToMap convert a json to a map * @return map[string]interface{} *
func (*Items) ValAny ¶
* * ValAny return the value of the key * @param idx int, def any, atribs ...string * @return any *
func (*Items) ValArray ¶
* * ValArray return the value of the key * @param idx int, def []interface{}, atribs ...string * @return []interface{} *
func (*Items) ValBool ¶
* * ValBool return bool value of the key * @param idx int, def bool, atribs ...string * @return bool *
func (*Items) ValInt ¶
* * ValInt return int value of the key * @param idx int, def int, atribs ...string * @return int *
func (*Items) ValInt64 ¶
* * ValInt64 return int64 value of the key * @param idx int64, def int64, atribs ...string * @return int64 *
func (*Items) ValJson ¶
* * ValJson return the value of the key * @param idx int, def Json, atribs ...string * @return Json *
func (*Items) ValNum ¶
* * ValNum return float64 value of the key * @param idx int, def float64, atribs ...string * @return float64 *
type Json ¶
type Json map[string]interface{}
* * Json type *
func ToJson ¶ added in v0.0.2
* * ToJson convert a string to a json * @param src string * @return Json, error *
func (Json) Any ¶
* * Any return any value of the key * @param def any * @param atribs ...string * @return *Any *
func (Json) Append ¶
* * Append: This method append the values in from to s. If the key exist in s, the value is not replaced. * @param from Json *
func (Json) ArrayInt64 ¶
* * ArrayInt64 * @param atribs ...string * @return []int64 *
func (Json) ArrayNumber ¶ added in v1.0.12
* * ArrayNumber * @param atribs ...string * @return []float64 *
func (Json) Byte ¶
* * Byte return the value of the key * @param atribs ...string * @return []byte *
func (Json) Compare ¶
* * Compare: This method return a new json with the diferent values between s and from. Also include the keys that not exist in s. * @param from Json * @return bool *
func (Json) Exist ¶ added in v1.0.20
* * Exist return if the key exist * @param key string * @return bool *
func (Json) FromBase64 ¶ added in v1.0.12
* * FromBase64 decode base64 value to string * @param atribs ...string * @return string *
func (Json) Int64 ¶
* * Int64 return the value of the key * @param atribs ...string * @return int64 *
func (Json) IsChanged ¶
* * IsChanged: This method return true if the values in s are different to the values in from. * @param from Json * @return bool *
func (Json) IsExist ¶ added in v1.0.12
* * IsExist return if the json has the key * @param key string * @return bool *
func (Json) Set ¶
* * Set a value in the key * @param key string * @param val interface{} * @return bool *
func (Json) String ¶
* * String return the value of the key * @param atribs ...string * @return string *
func (Json) Time ¶
* * Time return the value of the key * @param atribs ...string * @return time.Time *
func (Json) ToBase64 ¶ added in v1.0.12
* * ToBase64 encode string value to base64 * @param atribs ...string * @return string *
func (Json) ToEscapeHTML ¶ added in v0.1.19
* * ToEscapeHTML convert a json to a string without escape html * @return string *
func (Json) ToMap ¶ added in v0.1.17
* * ToMap convert a json to a map * @return map[string]interface{} *
func (Json) Update ¶
* * Update: This method update s with values in from. If the key exist in s, the value is replaced with the value in from. * @param fromJson Json * @return error *
func (Json) ValArray ¶
* * ValArray * @param def []interface{}, atribs ...string * @return []interface{} *
func (Json) ValBool ¶
* * ValBool return bool value of the key * @param def bool * @param atribs ...string * @return bool *
func (Json) ValInt ¶
* * ValInt return int value of the key * @param def int * @param atribs ...string * @return int *
func (Json) ValNum ¶
* * ValNum return float64 value of the key * @param def float64 * @param atribs ...string * @return float64 *
type List ¶
type List struct {
Rows int `json:"rows"`
All int `json:"all"`
Count int `json:"count"`
Page int `json:"page"`
Start int `json:"start"`
End int `json:"end"`
Result []Json `json:"result"`
}
List struct to use in et
type ObjectRule ¶ added in v1.0.20
type ObjectRule struct {
// contains filtered or unexported fields
}
func Object ¶
func Object(name string, rules ...Rule) *ObjectRule
func (*ObjectRule) Name ¶ added in v1.0.21
func (r *ObjectRule) Name() string
* * Name * @return string *
func (*ObjectRule) Validate ¶ added in v1.0.20
func (r *ObjectRule) Validate(j Json) error
* * Validate * @param j Json * @return error *
type PhoneRule ¶ added in v1.0.21
type PhoneRule struct {
// contains filtered or unexported fields
}
PhoneRule validates that a field contains a valid mobile phone number. By default it enforces E.164 format: + followed by 7–15 digits (e.g. +573001234567). Use CountryCode to restrict to a specific country calling code prefix (e.g. "+57").
func (*PhoneRule) CountryCode ¶ added in v1.0.21
* * CountryCode restricts the phone number to a given country calling code prefix. * @param code string — e.g. "+57", "+1", "+34" * @return *PhoneRule *
type StringRule ¶ added in v1.0.20
type StringRule struct {
// contains filtered or unexported fields
}
func Str ¶ added in v1.0.20
func Str(name string) *StringRule
* * Str * @param name string * @return *StringRule *
func (*StringRule) Name ¶ added in v1.0.21
func (r *StringRule) Name() string
* * Name * @return string *
func (*StringRule) NotEmpty ¶ added in v1.0.20
func (r *StringRule) NotEmpty() *StringRule
* * NotEmpty * @return *StringRule *
func (*StringRule) Validate ¶ added in v1.0.20
func (r *StringRule) Validate(j Json) error
* * Validate * @param j Json * @return error *