Thanks to visit codestin.com
Credit goes to github.com

Skip to content

v1.4.6 change has broken existing behaviour #192

@inhere

Description

@inhere

Regression

This change has broken existing behaviour.

For eg: I have a JSON:

{
  "main1": {
    "child11": 1,
    "child12": 2
  },
  "main2": {
    "child21": 5,
    "child22": 6
  }
}

Now, as per validation rules, key main1 and main2 are optional. And their respective children keys should be validated only when main key exists.

The validation rules are defined as:

type Request struct {
	Main1 *struct {
		Child11     string `json:"child11" validate:"required"`
		Child12 string `json:"child12" validate:"required"`
	} `json:"main1"`
	Main2 *struct {
		Child21 string `json:"child21" validate:"required"`
		Child22 string `json:"child22" validate:"required"`
	} `json:"main2"`
}

Earlier, uptil v1.4.5, these definitions were working fine and children struct was validated only when the respective main key existed

Now, with the release v1.4.6 , this behaviour does not work anymore as nil pointer check is removed.

Originally posted by @madhurbhaiya in #191 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requestedresolved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions