Skip to content

Enhanced ValidationCtx method to support nested map in slice #915

@leftjs

Description

@leftjs
  • I have looked at the documentation here first?
  • I have looked at the examples provided that may showcase my question here?

Package version eg. v9, v10:

v10

Issue, Question or Enhancement:

Enhanced ValidationCtx method to support nested map in slice

Currently ValidateCtx cannot support the validation method of nested map in slices, which makes ValidateCtx inconvenient to use. Can it be enhanced?

Code sample, to showcase or reproduce:

test data like this

data: map[string]interface{}{
	"Test_A": map[string]interface{}{
		"Test_B": "Test_B",
		"Test_C": []interface{}{"Test_D"},
		"Test_E": map[string]interface{}{
			"Test_F": "Test_F",
		},
		"Test_G": "Test_G",
		"Test_I": []map[string]interface{}{
			{
				"Test_J": "Test_J",
			},
		},
	},
},
rules: map[string]interface{}{
	"Test_A": map[string]interface{}{
		"Test_B": "min=2",
		"Test_C": map[string]interface{}{
			"Test_D": "min=2",
		},
		"Test_E": map[string]interface{}{
			"Test_F": "min=100",
		},
		"Test_G": map[string]interface{}{
			"Test_H": "min=2",
		},
		"Test_I": map[string]interface{}{
			"Test_J": "min=100",
		},
	},
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions