Skip to content

Commit

Permalink
bump source code
Browse files Browse the repository at this point in the history
  • Loading branch information
guiferpa committed Feb 1, 2025
1 parent 98a30a3 commit b8b09b0
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/guiferpa/gody/v2

go 1.22
go 1.23.5
4 changes: 2 additions & 2 deletions serialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ type Field struct {
Tags map[string]string
}

func Serialize(b interface{}) ([]Field, error) {
func Serialize(b any) ([]Field, error) {
return RawSerialize(DefaultTagName, b)
}

// RawSerialize is a func to serialize/parse all content about the struct input
func RawSerialize(tn string, b interface{}) ([]Field, error) {
func RawSerialize(tn string, b any) ([]Field, error) {
if tn == "" {
return nil, &ErrEmptyTagName{}
}
Expand Down
4 changes: 2 additions & 2 deletions serialize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type TestSerializeStructC struct {

func TestSerializeBodyStruct(t *testing.T) {
cases := []struct {
param interface{}
param any
ok bool
}{
{map[string]string{"test-key": "test-value"}, false},
Expand All @@ -45,7 +45,7 @@ func TestSerializeBodyStruct(t *testing.T) {

func TestSerializeBodyTagFormat(t *testing.T) {
cases := []struct {
param interface{}
param any
ok bool
}{
{struct {
Expand Down
8 changes: 4 additions & 4 deletions validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ package gody

import "github.com/guiferpa/gody/v2/rule"

func DefaultValidate(b interface{}, customRules []Rule) (bool, error) {
func DefaultValidate(b any, customRules []Rule) (bool, error) {
return RawDefaultValidate(b, DefaultTagName, customRules)
}

// Validate contains the entrypoint to validation of struct input
func Validate(b interface{}, rules []Rule) (bool, error) {
func Validate(b any, rules []Rule) (bool, error) {
return RawValidate(b, DefaultTagName, rules)
}

func RawDefaultValidate(b interface{}, tn string, customRules []Rule) (bool, error) {
func RawDefaultValidate(b any, tn string, customRules []Rule) (bool, error) {
defaultRules := []Rule{
rule.NotEmpty,
rule.Required,
Expand All @@ -26,7 +26,7 @@ func RawDefaultValidate(b interface{}, tn string, customRules []Rule) (bool, err
return RawValidate(b, tn, append(defaultRules, customRules...))
}

func RawValidate(b interface{}, tn string, rules []Rule) (bool, error) {
func RawValidate(b any, tn string, rules []Rule) (bool, error) {
fields, err := RawSerialize(tn, b)
if err != nil {
return false, err
Expand Down
2 changes: 1 addition & 1 deletion validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (v *Validator) SetTagName(tn string) error {
return nil
}

func (v *Validator) Validate(b interface{}) (bool, error) {
func (v *Validator) Validate(b any) (bool, error) {
return RawDefaultValidate(b, v.tagName, v.addedRules)
}

Expand Down

0 comments on commit b8b09b0

Please sign in to comment.