All Versions
5
Latest Version
Avg Release Cycle
74 days
Latest Release
1303 days ago

Changelog History

  • v2.2.0 Changes

    November 30, 2020

    ๐Ÿ”„ Changed structure for module version

    commit b12bd3f

  • v2.1.0 Changes

    November 30, 2020

    Loyalty on show field name

    If there is JSON tag on struct the gody will get the field name from json tag value

    Example where struct has a JSON tag

    type Response struct { FirstName string `validate:"not_empty" json:"fname"`}resp := Response{}if validated, err := validator.Validate(resp); err != nil { ...}// output error: field fname cannot be empty
    
    • Example where struct hasn't a JSON tag

      type Response struct { FirstName string validate:"not_empty"}resp := Response{}if validated, err := validator.Validate(resp); err != nil { ...}// output error: field firstName cannot be empty

    issue #13

  • v2.0.0 Changes

    April 14, 2020

    Validator struct

    • Validate more clean for source code

      validator := gody.NewValidator()if validated, err := validator.Validate(/*struct*/); err != nil { ... }

    • On demand rules

      ...if err := validator.AddRules(/*...rules*/); err != nil { ... } ...

    • ๐Ÿ‘ Support for set a custom tag name

      ...if err := validator.SetTagName(/*name*/); err != nil { ... } ...

    ๐Ÿ‘ Raw functions support

    • RawSerialize receive tag name and the struct to validate.

      func RawSerialize(tn string, b interface{}) ([]Field, error)

    • RawValidate receive the struct to validate, tag name and custom rules.

      func RawValidate(b interface{}, tn string, rules []Rule) (bool, error)

    • 0๏ธโƒฃ RawDefaultValidate receive the struct to validate, tag name and custom rules.

      func RawDefaultValidate(b interface{}, tn string, rules []Rule) (bool, error)

    ๐Ÿฑ > ๐Ÿ““ DefaultValidate and RawDefaultValidate it's same, both uses as default rules built-in gody.

    โœ‚ Remove the necessity for tag in struct and slice validation

    issue #9

  • v1.1.0 Changes

    April 01, 2020

    ๐Ÿ‘Œ Support rule parameter

    • Boolean rule (Any parameter will be a boolean value if it isn't setted) - Issue #6

    โš ๏ธ In case of custom rules , it'll receive a empty string in parameter value. The rule will decide if it's a either value boolean (true or false) or any other type value.

    type User struct { Name string `validate:"not\_empty"`Ageint`validate:"is\_adult"` // A custom rule} ...// Validate handle for is\_adult rulefunc Validate(field, value, parameter string) (bool, error) { fmt.Println(field) // Field name from struct fmt.Println(value) // Value of field from struct fmt.Println(parameter) // Value setted in tag validate for rule, it's a empty string// TODO: Validation for adult agereturn true, nil} ...
    

    ๐Ÿ‘Œ Support rules

    • NotEmpty (Verified if the field got some value) - Issue #7

    ๐Ÿฑ ๐Ÿ““ It's a boolean rule, whatever if it receive some parameter value as boolean or any other.

  • v1.0.0 Changes

    February 08, 2020

    ๐Ÿ‘Œ Support validations

    • Shallow validate (Validation on first layer from struct)
    • Deep validate (Validation on behind of first layers from struct)
    • Slice validate (Validation with slice or array in any level from struct)

    ๐Ÿ‘Œ Support rules

    • Required (Verified if the field got some value)
    • Enum (Verified the field if given some default values the got value is equals which one)
    • Min (Verified if the field got some value higher that given parameter)
    • Max (Verified if the field got some value less that given parameter)
    • Min bound (Verified if the field got some string length higher that given parameter)
    • Max bound (Verified if the field got some string length less that given parameter)

    ๐Ÿ‘Œ Support custom rules to validate