From 611b33b6e65fb1cf0eaec29c1390947fb1130e72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 26 Oct 2025 09:21:06 -0300 Subject: [PATCH 01/31] chore: remove useless code --- internal/codegenerator/get_test_elements_all_types_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/codegenerator/get_test_elements_all_types_test.go b/internal/codegenerator/get_test_elements_all_types_test.go index 8590870..ccb2982 100644 --- a/internal/codegenerator/get_test_elements_all_types_test.go +++ b/internal/codegenerator/get_test_elements_all_types_test.go @@ -1150,7 +1150,6 @@ func TestDefineTestElementsWithAllTypes(t *testing.T) { return } for _, fieldType := range fieldTypes { - // op, _, _ := strings.Cut(tt.validation, "=") validation := replaceValidationValue(tt.validation, check.value) want := TestElements{ concatOperator: check.want.concatOperator, From e3246038bfe469d8a26e4127093b79ba5088b125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 26 Oct 2025 09:32:57 -0300 Subject: [PATCH 02/31] feat: testgen building end-to-end tests --- testgen/generate_tests.go | 13 + testgen/generate_validation_types_tests.go | 144 ++++ testgen/no_pointer_tests.tpl | 50 ++ testgen/pointer_tests.tpl | 58 ++ testgen/validations.go | 877 +++++++++++++++++++++ 5 files changed, 1142 insertions(+) create mode 100644 testgen/generate_tests.go create mode 100644 testgen/generate_validation_types_tests.go create mode 100644 testgen/no_pointer_tests.tpl create mode 100644 testgen/pointer_tests.tpl create mode 100644 testgen/validations.go diff --git a/testgen/generate_tests.go b/testgen/generate_tests.go new file mode 100644 index 0000000..154d76d --- /dev/null +++ b/testgen/generate_tests.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" +) + +func main() { + fmt.Println("Generating tests files") + + generateValidationTypesTests() + + fmt.Println("Generating done") +} diff --git a/testgen/generate_validation_types_tests.go b/testgen/generate_validation_types_tests.go new file mode 100644 index 0000000..9b53221 --- /dev/null +++ b/testgen/generate_validation_types_tests.go @@ -0,0 +1,144 @@ +package main + +import ( + "bytes" + "fmt" + "go/format" + "log" + "os" + "strings" + "text/template" + + "github.com/opencodeco/validgen/internal/common" + "golang.org/x/text/cases" + "golang.org/x/text/language" +) + +type AllTestCasesToGenerate struct { + TestCases []TestCaseToGenerate +} + +type TestCaseToGenerate struct { + StructName string + Tests []TestCase +} + +type TestCase struct { + FieldName string + Validation string + FieldType string + BasicType string + ValidCase string + InvalidCase string + ErrorMessage string +} + +func generateValidationTypesTests() { + generateValidationTypesTestsFile("no_pointer_tests.tpl", "generated_no_pointer_tests.go", false) + generateValidationTypesTestsFile("pointer_tests.tpl", "generated_pointer_tests.go", true) +} + +func generateValidationTypesTestsFile(tpl, dest string, pointer bool) { + log.Printf("Generating validation types test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) + + allTestsToGenerate := AllTestCasesToGenerate{} + + for _, testCase := range typesValidation { + structName := testCase.tag + "StructFields" + if pointer { + structName += "Pointer" + } + allTestsToGenerate.TestCases = append(allTestsToGenerate.TestCases, TestCaseToGenerate{ + StructName: structName, + }) + for _, toGenerate := range testCase.testCases { + // Default ("") gen no pointer and pointer test. + if toGenerate.generateFor != "" { + if toGenerate.generateFor == "pointer" && !pointer { + continue + } + if toGenerate.generateFor == "nopointer" && pointer { + continue + } + } + normalizedType := toGenerate.typeClass + if pointer { + normalizedType = "*" + normalizedType + } + fTypes := common.HelperFromNormalizedToBasicTypes(normalizedType) + sNames := common.HelperFromNormalizedToStringNames(normalizedType) + for i := range fTypes { + validation := testCase.tag + if testCase.argsCount != common.ZeroValue { + validation += "=" + toGenerate.validation + } + fieldName := "Field" + cases.Title(language.Und).String(testCase.tag) + sNames[i] + basicType, _ := strings.CutPrefix(fTypes[i], "*") + + errorMessage := toGenerate.errorMessage + errorMessage = strings.ReplaceAll(errorMessage, "{{.FieldName}}", fieldName) + errorMessage = strings.ReplaceAll(errorMessage, "{{.Target}}", toGenerate.validation) + errorMessage = strings.ReplaceAll(errorMessage, "{{.Targets}}", targetsInMessage(toGenerate.validation)) + + allTestsToGenerate.TestCases[len(allTestsToGenerate.TestCases)-1].Tests = append(allTestsToGenerate.TestCases[len(allTestsToGenerate.TestCases)-1].Tests, TestCase{ + FieldName: fieldName, + Validation: validation, + FieldType: fTypes[i], + BasicType: basicType, + ValidCase: strings.ReplaceAll(toGenerate.validCase, "{{.BasicType}}", basicType), + InvalidCase: strings.ReplaceAll(toGenerate.invalidCase, "{{.BasicType}}", basicType), + ErrorMessage: errorMessage, + }) + } + } + } + + if err := allTestsToGenerate.GenerateFile(tpl, dest); err != nil { + log.Fatalf("error generation validation types file %s", err) + } + + log.Printf("Generating %s done\n", dest) +} + +func (at *AllTestCasesToGenerate) GenerateFile(tplFile, output string) error { + tpl, err := os.ReadFile(tplFile) + if err != nil { + return fmt.Errorf("error reading %s: %s", tplFile, err) + } + + tmpl, err := template.New("ValidationTypesTests").Parse(string(tpl)) + if err != nil { + return err + } + + code := new(bytes.Buffer) + if err := tmpl.Execute(code, at); err != nil { + return err + } + + // if err := os.WriteFile(output, code.Bytes(), 0644); err != nil { + // return err + // } + + formattedCode, err := format.Source(code.Bytes()) + if err != nil { + return err + } + + if err := os.WriteFile(output, formattedCode, 0644); err != nil { + return err + } + + return nil +} + +func targetsInMessage(validation string) string { + tokens := strings.Split(validation, " ") + + msg := "" + for _, token := range tokens { + msg += "'" + token + "' " + } + + return strings.TrimSpace(msg) +} diff --git a/testgen/no_pointer_tests.tpl b/testgen/no_pointer_tests.tpl new file mode 100644 index 0000000..8badfdf --- /dev/null +++ b/testgen/no_pointer_tests.tpl @@ -0,0 +1,50 @@ +// Code generated by TestGenerator. DO NOT EDIT. + +package main + +import ( + "log" +) + +func noPointerTests() { +{{range .TestCases}}{{.StructName}}Tests() +{{end}} +} + +{{range .TestCases}} + +type {{.StructName}} struct { + {{range .Tests}}{{.FieldName}} {{.FieldType}} `valid:"{{.Validation}}"` + {{end}} +} + +func {{.StructName}}Tests() { + log.Println("starting {{.StructName}} types tests") + + var expectedMsgErrors []string + var errs []error + + // Test case 1: All failure scenarios (invalid cases) + v := &{{.StructName}}{} + expectedMsgErrors = []string{ + {{range .Tests}}"{{.ErrorMessage}}", + {{end}} + } + + {{range .Tests}}{{ if ne .InvalidCase "--" }}v.{{.FieldName}} = {{.InvalidCase}}{{end}} + {{end}} + errs = {{.StructName}}Validate(v) + assertExpectedErrorMsgs("testcase 1", errs, expectedMsgErrors) + + // Test case 2: All valid cases + v = &{{.StructName}}{} + {{range .Tests}}v.{{.FieldName}} = {{.ValidCase}} + {{end}} + expectedMsgErrors = nil + errs = {{.StructName}}Validate(v) + assertExpectedErrorMsgs("testcase 2", errs, expectedMsgErrors) + + log.Println("{{.StructName}} types tests ok") +} + +{{end}} \ No newline at end of file diff --git a/testgen/pointer_tests.tpl b/testgen/pointer_tests.tpl new file mode 100644 index 0000000..6528758 --- /dev/null +++ b/testgen/pointer_tests.tpl @@ -0,0 +1,58 @@ +// Code generated by TestGenerator. DO NOT EDIT. + +package main + +import ( + "log" +) + +func pointerTests() { +{{range .TestCases}}{{.StructName}}Tests() +{{end}} +} + +{{range .TestCases}} + +type {{.StructName}} struct { + {{range .Tests}}{{.FieldName}} {{.FieldType}} `valid:"{{.Validation}}"` + {{end}} +} + +func {{.StructName}}Tests() { + log.Println("starting {{.StructName}} types tests") + + var expectedMsgErrors []string + var errs []error + + // Test case 1: All failure scenarios (nil values) + v := &{{.StructName}}{} + expectedMsgErrors = []string{ + {{range .Tests}}"{{.ErrorMessage}}", + {{end}} + } + errs = {{.StructName}}Validate(v) + assertExpectedErrorMsgs("testcase 1", errs, expectedMsgErrors) + + // Test case 2: All failure scenarios (invalid cases) + {{range .Tests}}{{ if ne .InvalidCase "--" }}var Invalid{{.FieldName}} {{.BasicType}} = {{.InvalidCase}}{{end}} + {{end}} + v = &{{.StructName}}{} + {{range .Tests}}{{ if ne .InvalidCase "--" }}v.{{.FieldName}} = &Invalid{{.FieldName}}{{end}} + {{end}} + errs = {{.StructName}}Validate(v) + assertExpectedErrorMsgs("testcase 2", errs, expectedMsgErrors) + + // Test case 3: All valid cases + {{range .Tests}}var Valid{{.FieldName}} {{.BasicType}} = {{.ValidCase}} + {{end}} + v = &{{.StructName}}{} + {{range .Tests}}v.{{.FieldName}} = &Valid{{.FieldName}} + {{end}} + expectedMsgErrors = nil + errs = {{.StructName}}Validate(v) + assertExpectedErrorMsgs("testcase 3", errs, expectedMsgErrors) + + log.Println("{{.StructName}} types tests ok") +} + +{{end}} \ No newline at end of file diff --git a/testgen/validations.go b/testgen/validations.go new file mode 100644 index 0000000..c0c5661 --- /dev/null +++ b/testgen/validations.go @@ -0,0 +1,877 @@ +package main + +import "github.com/opencodeco/validgen/internal/common" + +type typeValidation struct { + typeClass string + validation string + validCase string + invalidCase string + errorMessage string + generateFor string +} + +var typesValidation = []struct { + tag string + validatorTag string + isFieldValidation bool + argsCount common.CountValues + testCases []typeValidation +}{ + // email operations + { + tag: "email", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.ZeroValue, + testCases: []typeValidation{ + { + // email: "" + typeClass: ``, + validation: ``, + validCase: `"abcde@example.com"`, + invalidCase: `"abcde@example"`, + errorMessage: `{{.FieldName}} must be a valid email`, + }, + }, + }, + + // required operations + { + tag: "required", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.ZeroValue, + testCases: []typeValidation{ + // required: "", "", "", "" + { + typeClass: ``, + validation: ``, + validCase: `"abcde"`, + invalidCase: `""`, + errorMessage: `{{.FieldName}} is required`, + }, + { + typeClass: ``, + validation: ``, + validCase: `32`, + invalidCase: `0`, + errorMessage: `{{.FieldName}} is required`, + }, + { + typeClass: ``, + validation: ``, + validCase: `12.34`, + invalidCase: `0`, + errorMessage: `{{.FieldName}} is required`, + }, + { + typeClass: ``, + validation: ``, + validCase: `true`, + invalidCase: `false`, + errorMessage: `{{.FieldName}} is required`, + }, + + // required: "[]", "[]", "[]", "[]" + { + typeClass: `[]`, + validation: ``, + validCase: `{{.BasicType}}{"abcde"}`, + invalidCase: `{{.BasicType}}{}`, + errorMessage: `{{.FieldName}} must not be empty`, + }, + { + typeClass: `[]`, + validation: ``, + validCase: `{{.BasicType}}{32}`, + invalidCase: `{{.BasicType}}{}`, + errorMessage: `{{.FieldName}} must not be empty`, + }, + { + typeClass: `[]`, + validation: ``, + validCase: `{{.BasicType}}{12.34}`, + invalidCase: `{{.BasicType}}{}`, + errorMessage: `{{.FieldName}} must not be empty`, + }, + { + typeClass: `[]`, + validation: ``, + validCase: `{{.BasicType}}{true}`, + invalidCase: `{{.BasicType}}{}`, + errorMessage: `{{.FieldName}} must not be empty`, + }, + + // required: "[N]", "[N]", "[N]", "[N]" + { + typeClass: `[N]`, + validation: ``, + validCase: `{{.BasicType}}{"abcde"}`, + invalidCase: `--`, + errorMessage: `{{.FieldName}} must not be empty`, + generateFor: "pointer", + }, + { + typeClass: `[N]`, + validation: ``, + validCase: `{{.BasicType}}{32}`, + invalidCase: `--`, + errorMessage: `{{.FieldName}} must not be empty`, + generateFor: "pointer", + }, + { + typeClass: `[N]`, + validation: ``, + validCase: `{{.BasicType}}{12.34}`, + invalidCase: `--`, + errorMessage: `{{.FieldName}} must not be empty`, + generateFor: "pointer", + }, + { + typeClass: `[N]`, + validation: ``, + validCase: `{{.BasicType}}{true}`, + invalidCase: `--`, + errorMessage: `{{.FieldName}} must not be empty`, + generateFor: "pointer", + }, + + // required: "map[]", "map[]", "map[]", "map[]" + { + typeClass: `map[]`, + validation: ``, + validCase: `{{.BasicType}}{"abcde":"value"}`, + invalidCase: `{{.BasicType}}{}`, + errorMessage: `{{.FieldName}} must not be empty`, + }, + { + typeClass: `map[]`, + validation: ``, + validCase: `{{.BasicType}}{32:64}`, + invalidCase: `{{.BasicType}}{}`, + errorMessage: `{{.FieldName}} must not be empty`, + }, + { + typeClass: `map[]`, + validation: ``, + validCase: `{{.BasicType}}{12.34:56.78}`, + invalidCase: `{{.BasicType}}{}`, + errorMessage: `{{.FieldName}} must not be empty`, + }, + { + typeClass: `map[]`, + validation: ``, + validCase: `{{.BasicType}}{true:true}`, + invalidCase: `{{.BasicType}}{}`, + errorMessage: `{{.FieldName}} must not be empty`, + }, + }, + }, + + // eq operations + { + tag: "eq", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // eq: "", "", "", "" + { + typeClass: ``, + validation: `abcde`, + validCase: `"abcde"`, + invalidCase: `"fghij"`, + errorMessage: `{{.FieldName}} must be equal to '{{.Target}}'`, + }, + { + typeClass: ``, + validation: `32`, + validCase: `32`, + invalidCase: `64`, + errorMessage: `{{.FieldName}} must be equal to {{.Target}}`, + }, + { + typeClass: ``, + validation: `12.34`, + validCase: `12.34`, + invalidCase: `34.56`, + errorMessage: `{{.FieldName}} must be equal to {{.Target}}`, + }, + { + typeClass: ``, + validation: `true`, + validCase: `true`, + invalidCase: `false`, + errorMessage: `{{.FieldName}} must be equal to {{.Target}}`, + }, + }, + }, + + // neq operations + { + tag: "neq", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // neq: "", "", "", "" + { + typeClass: ``, + validation: `abcde`, + validCase: `"fghij"`, + invalidCase: `"abcde"`, + errorMessage: `{{.FieldName}} must not be equal to '{{.Target}}'`, + }, + { + typeClass: ``, + validation: `32`, + validCase: `64`, + invalidCase: `32`, + errorMessage: `{{.FieldName}} must not be equal to {{.Target}}`, + }, + { + typeClass: ``, + validation: `12.34`, + validCase: `34.56`, + invalidCase: `12.34`, + errorMessage: `{{.FieldName}} must not be equal to {{.Target}}`, + }, + { + typeClass: ``, + validation: `true`, + validCase: `false`, + invalidCase: `true`, + errorMessage: `{{.FieldName}} must not be equal to {{.Target}}`, + }, + }, + }, + + // gt operations + { + tag: "gt", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // gt: "", "" + { + typeClass: ``, + validation: `32`, + validCase: `33`, + invalidCase: `31`, + errorMessage: `{{.FieldName}} must be > {{.Target}}`, + }, + { + typeClass: ``, + validation: `12.34`, + validCase: `12.35`, + invalidCase: `12.34`, + errorMessage: `{{.FieldName}} must be > {{.Target}}`, + }, + }, + }, + + // gte operations + { + tag: "gte", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // gte: "", "" + { + typeClass: ``, + validation: `32`, + validCase: `32`, + invalidCase: `31`, + errorMessage: `{{.FieldName}} must be >= {{.Target}}`, + }, + { + typeClass: ``, + validation: `12.34`, + validCase: `12.34`, + invalidCase: `12.33`, + errorMessage: `{{.FieldName}} must be >= {{.Target}}`, + }, + }, + }, + + // lt operations + { + tag: "lt", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // lt: "", "" + { + typeClass: ``, + validation: `32`, + validCase: `31`, + invalidCase: `33`, + errorMessage: `{{.FieldName}} must be < {{.Target}}`, + }, + { + typeClass: ``, + validation: `12.34`, + validCase: `12.33`, + invalidCase: `12.35`, + errorMessage: `{{.FieldName}} must be < {{.Target}}`, + }, + }, + }, + + // lte operations + { + tag: "lte", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // lte: "", "" + { + typeClass: ``, + validation: `32`, + validCase: `32`, + invalidCase: `33`, + errorMessage: `{{.FieldName}} must be <= {{.Target}}`, + }, + { + typeClass: ``, + validation: `12.34`, + validCase: `12.34`, + invalidCase: `12.35`, + errorMessage: `{{.FieldName}} must be <= {{.Target}}`, + }, + }, + }, + + // min operations + { + tag: "min", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // min: "" + { + typeClass: ``, + validation: `5`, + validCase: `"abcde"`, + invalidCase: `"abc"`, + errorMessage: `{{.FieldName}} length must be >= {{.Target}}`, + }, + + // min: "[]", "[]", "[]", "[]" + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{"abc", "def"}`, + invalidCase: `{{.BasicType}}{"abc"}`, + errorMessage: `{{.FieldName}} must have at least {{.Target}} elements`, + }, + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{65, 67}`, + invalidCase: `{{.BasicType}}{65}`, + errorMessage: `{{.FieldName}} must have at least {{.Target}} elements`, + }, + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{65.65, 67.67}`, + invalidCase: `{{.BasicType}}{65.65}`, + errorMessage: `{{.FieldName}} must have at least {{.Target}} elements`, + }, + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{true, false}`, + invalidCase: `{{.BasicType}}{true}`, + errorMessage: `{{.FieldName}} must have at least {{.Target}} elements`, + }, + + // min: "map[]", "map[]", "map[]", "map[]" + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{"a": "1", "b": "2"}`, + invalidCase: `{{.BasicType}}{"a": "1"}`, + errorMessage: `{{.FieldName}} must have at least {{.Target}} elements`, + }, + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{1: 65, 2: 67}`, + invalidCase: `{{.BasicType}}{1: 65}`, + errorMessage: `{{.FieldName}} must have at least {{.Target}} elements`, + }, + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{1: 65.65, 2: 67.67}`, + invalidCase: `{{.BasicType}}{1: 65.65}`, + errorMessage: `{{.FieldName}} must have at least {{.Target}} elements`, + }, + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{true: true, false: false}`, + invalidCase: `{{.BasicType}}{true: true}`, + errorMessage: `{{.FieldName}} must have at least {{.Target}} elements`, + }, + }, + }, + + // max operations + { + tag: "max", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // max: "" + { + typeClass: ``, + validation: `3`, + validCase: `"abc"`, + invalidCase: `"abcde"`, + errorMessage: `{{.FieldName}} length must be <= 3`, + }, + + // max: "[]", "[]", "[]", "[]" + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{"abc", "def"}`, + invalidCase: `{{.BasicType}}{"abc", "def", "ghi"}`, + errorMessage: `{{.FieldName}} must have at most {{.Target}} elements`, + }, + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{65, 67}`, + invalidCase: `{{.BasicType}}{65, 66, 67}`, + errorMessage: `{{.FieldName}} must have at most {{.Target}} elements`, + }, + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{65.65, 67.67}`, + invalidCase: `{{.BasicType}}{65.65, 66.66, 67.67}`, + errorMessage: `{{.FieldName}} must have at most {{.Target}} elements`, + }, + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{true, false}`, + invalidCase: `{{.BasicType}}{true, false, true}`, + errorMessage: `{{.FieldName}} must have at most {{.Target}} elements`, + }, + + // max: "map[]", "map[]", "map[]", "map[]" + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{"a": "1", "b": "2"}`, + invalidCase: `{{.BasicType}}{"a": "1", "b": "2", "c": "3"}`, + errorMessage: `{{.FieldName}} must have at most {{.Target}} elements`, + }, + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{1: 65, 2: 67}`, + invalidCase: `{{.BasicType}}{1: 65, 2: 67, 3: 68}`, + errorMessage: `{{.FieldName}} must have at most {{.Target}} elements`, + }, + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{1: 65.65, 2: 67.67}`, + invalidCase: `{{.BasicType}}{1: 65.65, 2: 66.66, 3: 67.67}`, + errorMessage: `{{.FieldName}} must have at most {{.Target}} elements`, + }, + { + typeClass: `map[]`, + validation: `1`, + validCase: `{{.BasicType}}{true: true}`, + invalidCase: `{{.BasicType}}{true: true, false: false}`, + errorMessage: `{{.FieldName}} must have at most {{.Target}} elements`, + }, + }, + }, + + // eq_ignore_case operations + { + tag: "eq_ignore_case", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // eq_ignore_case: "" + { + typeClass: ``, + validation: `abcde`, + validCase: `"AbCdE"`, + invalidCase: `"a1b2c3"`, + errorMessage: `{{.FieldName}} must be equal to '{{.Target}}'`, + }, + }, + }, + + // neq_ignore_case operations + { + tag: "neq_ignore_case", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // neq_ignore_case: "" + { + typeClass: ``, + validation: `abcde`, + validCase: `"a1b2c3"`, + invalidCase: `"AbCdE"`, + errorMessage: `{{.FieldName}} must not be equal to '{{.Target}}'`, + }, + }, + }, + + // len operations + { + tag: "len", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.OneValue, + testCases: []typeValidation{ + // len: "" + { + typeClass: ``, + validation: `2`, + validCase: `"ab"`, + invalidCase: `"abcde"`, + errorMessage: `{{.FieldName}} length must be {{.Target}}`, + }, + + // len: "[]", "[]", "[]", "[]" + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{"abc", "def"}`, + invalidCase: `{{.BasicType}}{"abc", "def", "ghi"}`, + errorMessage: `{{.FieldName}} must have exactly {{.Target}} elements`, + }, + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{65, 67}`, + invalidCase: `{{.BasicType}}{65, 66, 67}`, + errorMessage: `{{.FieldName}} must have exactly {{.Target}} elements`, + }, + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{65.65, 67.67}`, + invalidCase: `{{.BasicType}}{65.65, 66.66, 67.67}`, + errorMessage: `{{.FieldName}} must have exactly {{.Target}} elements`, + }, + { + typeClass: `[]`, + validation: `2`, + validCase: `{{.BasicType}}{true, false}`, + invalidCase: `{{.BasicType}}{true, false, true}`, + errorMessage: `{{.FieldName}} must have exactly {{.Target}} elements`, + }, + + // len: "map[]", "map[]", "map[]", "map[]" + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{"a": "1", "b": "2"}`, + invalidCase: `{{.BasicType}}{"a": "1", "b": "2", "c": "3"}`, + errorMessage: `{{.FieldName}} must have exactly {{.Target}} elements`, + }, + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{1: 65, 2: 67}`, + invalidCase: `{{.BasicType}}{1: 65, 2: 67, 3: 68}`, + errorMessage: `{{.FieldName}} must have exactly {{.Target}} elements`, + }, + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{1: 65.65, 2: 67.67}`, + invalidCase: `{{.BasicType}}{1: 65.65, 2: 66.66, 3: 67.67}`, + errorMessage: `{{.FieldName}} must have exactly {{.Target}} elements`, + }, + { + typeClass: `map[]`, + validation: `2`, + validCase: `{{.BasicType}}{true: true, false: false}`, + invalidCase: `{{.BasicType}}{true: true}`, + errorMessage: `{{.FieldName}} must have exactly {{.Target}} elements`, + }, + }, + }, + + // in operations + { + tag: "in", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.ManyValues, + testCases: []typeValidation{ + // in: "", "", "", "" + { + typeClass: ``, + validation: `ab cd ef`, + validCase: `"cd"`, + invalidCase: `"fg"`, + errorMessage: `{{.FieldName}} must be one of {{.Targets}}`, + }, + { + typeClass: ``, + validation: `12 34 56`, + validCase: `34`, + invalidCase: `78`, + errorMessage: `{{.FieldName}} must be one of {{.Targets}}`, + }, + { + typeClass: ``, + validation: `11.11 22.22 33.33`, + validCase: `22.22`, + invalidCase: `44.44`, + errorMessage: `{{.FieldName}} must be one of {{.Targets}}`, + }, + { + typeClass: ``, + validation: `true`, + validCase: `true`, + invalidCase: `false`, + errorMessage: `{{.FieldName}} must be one of {{.Targets}}`, + }, + + // in: "[]", "[]", "[]", "[]" + { + typeClass: `[]`, + validation: `ab cd ef`, + validCase: `{{.BasicType}}{"ab", "ef"}`, + invalidCase: `{{.BasicType}}{"ab", "gh", "ef"}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + { + typeClass: `[]`, + validation: `12 34 56`, + validCase: `{{.BasicType}}{12, 56}`, + invalidCase: `{{.BasicType}}{12, 78, 56}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + { + typeClass: `[]`, + validation: `11.11 22.22 33.33`, + validCase: `{{.BasicType}}{11.11, 22.22}`, + invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + { + typeClass: `[]`, + validation: `true`, + validCase: `{{.BasicType}}{true, true}`, + invalidCase: `{{.BasicType}}{true, false, true}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + + // in: "[]", "[]", "[]", "[]" + { + typeClass: `[N]`, + validation: `ab cd ef`, + validCase: `{{.BasicType}}{"ab", "ef", "ab"}`, + invalidCase: `{{.BasicType}}{"ab", "gh", "ef"}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + { + typeClass: `[N]`, + validation: `12 34 56`, + validCase: `{{.BasicType}}{12, 56, 12}`, + invalidCase: `{{.BasicType}}{12, 78, 56}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + { + typeClass: `[N]`, + validation: `11.11 22.22 33.33`, + validCase: `{{.BasicType}}{11.11, 22.22, 11.11}`, + invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + { + typeClass: `[N]`, + validation: `true`, + validCase: `{{.BasicType}}{true, true, true}`, + invalidCase: `{{.BasicType}}{true, false, true}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + + // in: "map[]", "map[]", "map[]", "map[]" + { + typeClass: `map[]`, + validation: `a b c`, + validCase: `{{.BasicType}}{"a": "1", "b": "2", "c": "3"}`, + invalidCase: `{{.BasicType}}{"a": "1", "d": "9", "c": "3"}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + { + typeClass: `map[]`, + validation: `1 2 3`, + validCase: `{{.BasicType}}{1: 65, 2: 67, 3: 68}`, + invalidCase: `{{.BasicType}}{1: 65, 4: 69, 3: 68}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + { + typeClass: `map[]`, + validation: `11.11 22.22 33.33`, + validCase: `{{.BasicType}}{11.11: 11.11, 22.22: 22.22, 33.33: 33.33}`, + invalidCase: `{{.BasicType}}{11.11: 11.11, 44.44: 44.44, 33.33: 33.33}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + { + typeClass: `map[]`, + validation: `false`, + validCase: `{{.BasicType}}{false: false}`, + invalidCase: `{{.BasicType}}{true: true, false: false}`, + errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + }, + }, + }, + + // nin operations + { + tag: "nin", + validatorTag: ``, + isFieldValidation: false, + argsCount: common.ManyValues, + testCases: []typeValidation{ + // nin: "[]", "[]", "[]", "[]" + { + typeClass: ``, + validation: `ab cd ef`, + validCase: `"fg"`, + invalidCase: `"cd"`, + errorMessage: `{{.FieldName}} must not be one of {{.Targets}}`, + }, + { + typeClass: ``, + validation: `12 34 56`, + validCase: `78`, + invalidCase: `34`, + errorMessage: `{{.FieldName}} must not be one of {{.Targets}}`, + }, + { + typeClass: ``, + validation: `11.11 22.22 33.33`, + validCase: `44.44`, + invalidCase: `22.22`, + errorMessage: `{{.FieldName}} must not be one of {{.Targets}}`, + }, + { + typeClass: ``, + validation: `true`, + validCase: `false`, + invalidCase: `true`, + errorMessage: `{{.FieldName}} must not be one of {{.Targets}}`, + }, + + // nin: "[]", "[]", "[]", "[]" + { + typeClass: `[]`, + validation: `ab cd ef`, + validCase: `{{.BasicType}}{"gh", "ij", "kl"}`, + invalidCase: `{{.BasicType}}{"ab", "ef"}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + { + typeClass: `[]`, + validation: `12 34 56`, + validCase: `{{.BasicType}}{78, 91}`, + invalidCase: `{{.BasicType}}{12, 78, 56}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + { + typeClass: `[]`, + validation: `11.11 22.22 33.33`, + validCase: `{{.BasicType}}{44.44, 55.55, 66.66}`, + invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + { + typeClass: `[]`, + validation: `true`, + validCase: `{{.BasicType}}{false, false, false}`, + invalidCase: `{{.BasicType}}{true, false, true}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + + // nin: "[]", "[]", "[]", "[]" + { + typeClass: `[N]`, + validation: `ab cd ef`, + validCase: `{{.BasicType}}{"gh", "ij", "kl"}`, + invalidCase: `{{.BasicType}}{"ab", "gh", "ef"}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + { + typeClass: `[N]`, + validation: `12 34 56`, + validCase: `{{.BasicType}}{78, 91, 23}`, + invalidCase: `{{.BasicType}}{12, 78, 56}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + { + typeClass: `[N]`, + validation: `11.11 22.22 33.33`, + validCase: `{{.BasicType}}{44.44, 55.55, 66.66}`, + invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + { + typeClass: `[N]`, + validation: `true`, + validCase: `{{.BasicType}}{false, false, false}`, + invalidCase: `{{.BasicType}}{true, false, true}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + + // nin: "map[]", "map[]", "map[]", "map[]" + { + typeClass: `map[]`, + validation: `a b c`, + validCase: `{{.BasicType}}{"d": "1", "e": "2", "f": "3"}`, + invalidCase: `{{.BasicType}}{"a": "1", "d": "9", "c": "3"}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + { + typeClass: `map[]`, + validation: `1 2 3`, + validCase: `{{.BasicType}}{5: 55, 6: 66, 7: 77}`, + invalidCase: `{{.BasicType}}{1: 11, 4: 44, 3: 33}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + { + typeClass: `map[]`, + validation: `11.11 22.22 33.33`, + validCase: `{{.BasicType}}{44.44: 44.44, 55.55: 55.55, 66.66: 66.66}`, + invalidCase: `{{.BasicType}}{11.11: 11.11, 44.44: 44.44, 33.33: 33.33}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + { + typeClass: `map[]`, + validation: `false`, + validCase: `{{.BasicType}}{true: true}`, + invalidCase: `{{.BasicType}}{true: true, false: false}`, + errorMessage: `{{.FieldName}} elements must not be one of {{.Targets}}`, + }, + }, + }, +} From 2cdca9917b9d57923c89a9f336dd895d0e1c13da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 26 Oct 2025 13:01:02 -0300 Subject: [PATCH 03/31] chore: turn public GenValidations api --- .../build_func_validator_test.go | 2 +- internal/codegenerator/build_validator.go | 10 +++---- .../codegenerator/build_validator_test.go | 26 +++++++++---------- internal/codegenerator/codegen.go | 4 +-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/codegenerator/build_func_validator_test.go b/internal/codegenerator/build_func_validator_test.go index 48741a2..6108d9a 100644 --- a/internal/codegenerator/build_func_validator_test.go +++ b/internal/codegenerator/build_func_validator_test.go @@ -173,7 +173,7 @@ return errs for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gv := genValidations{ + gv := GenValidations{ Struct: tt.fields.Struct, } got, err := gv.BuildFuncValidatorCode() diff --git a/internal/codegenerator/build_validator.go b/internal/codegenerator/build_validator.go index 0ff1891..07a3f2b 100644 --- a/internal/codegenerator/build_validator.go +++ b/internal/codegenerator/build_validator.go @@ -27,12 +27,12 @@ type fieldTpl struct { Validations []*analyzer.Validation } -func (gv *genValidations) BuildFuncValidatorCode() (string, error) { +func (gv *GenValidations) BuildFuncValidatorCode() (string, error) { stTpl := StructToTpl(gv.Struct) funcMap := template.FuncMap{ - "buildValidationCode": gv.buildValidationCode, + "buildValidationCode": gv.BuildValidationCode, } tmpl, err := template.New("FuncValidator").Funcs(funcMap).Parse(funcValidatorTpl) @@ -48,7 +48,7 @@ func (gv *genValidations) BuildFuncValidatorCode() (string, error) { return code.String(), nil } -func (gv *genValidations) buildValidationCode(fieldName string, fieldType common.FieldType, fieldValidations []*analyzer.Validation) (string, error) { +func (gv *GenValidations) BuildValidationCode(fieldName string, fieldType common.FieldType, fieldValidations []*analyzer.Validation) (string, error) { tests := "" for _, fieldValidation := range fieldValidations { @@ -73,7 +73,7 @@ func (gv *genValidations) buildValidationCode(fieldName string, fieldType common return tests, nil } -func (gv *genValidations) buildIfCode(fieldName string, fieldType common.FieldType, fieldValidation *analyzer.Validation) (string, error) { +func (gv *GenValidations) buildIfCode(fieldName string, fieldType common.FieldType, fieldValidation *analyzer.Validation) (string, error) { testElements, err := DefineTestElements(fieldName, fieldType, fieldValidation) if err != nil { return "", fmt.Errorf("field %s: %w", fieldName, err) @@ -95,7 +95,7 @@ errs = append(errs, types.NewValidationError("%s")) `, booleanCondition, testElements.errorMessage), nil } -func (gv *genValidations) buildIfNestedCode(fieldName string, fieldType common.FieldType) (string, error) { +func (gv *GenValidations) buildIfNestedCode(fieldName string, fieldType common.FieldType) (string, error) { _, ok := gv.StructsWithValidation[fieldType.BaseType] if !ok { return "", fmt.Errorf("no validator found for struct type %s", fieldType) diff --git a/internal/codegenerator/build_validator_test.go b/internal/codegenerator/build_validator_test.go index c5bfcf6..ae53669 100644 --- a/internal/codegenerator/build_validator_test.go +++ b/internal/codegenerator/build_validator_test.go @@ -9,7 +9,7 @@ import ( "github.com/opencodeco/validgen/internal/parser" ) -func TestBuildValidationCode(t *testing.T) { +func TestBuildValidationCodeOld(t *testing.T) { type args struct { fieldName string fieldType common.FieldType @@ -259,15 +259,15 @@ errs = append(errs, types.NewValidationError("mapField must have exactly 3 eleme for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gv := genValidations{} + gv := GenValidations{} validation := AssertParserValidation(t, tt.args.fieldValidation) - got, err := gv.buildValidationCode(tt.args.fieldName, tt.args.fieldType, []*analyzer.Validation{validation}) + got, err := gv.BuildValidationCode(tt.args.fieldName, tt.args.fieldType, []*analyzer.Validation{validation}) if err != nil { - t.Errorf("buildValidationCode() error = %v, wantErr %v", err, nil) + t.Errorf("BuildValidationCode() error = %v, wantErr %v", err, nil) return } if got != tt.want { - t.Errorf("buildValidationCode() = %v, want %v", got, tt.want) + t.Errorf("BuildValidationCode() = %v, want %v", got, tt.want) } }) } @@ -330,7 +330,7 @@ errs = append(errs, types.NewValidationError("Field must have at least 2 element for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gv := genValidations{ + gv := GenValidations{ Struct: &analyzer.Struct{ Struct: parser.Struct{ PackageName: "main", @@ -340,13 +340,13 @@ errs = append(errs, types.NewValidationError("Field must have at least 2 element } gv.StructsWithValidation[tt.args.fieldType.BaseType] = struct{}{} validation := AssertParserValidation(t, tt.args.fieldValidation) - got, err := gv.buildValidationCode(tt.args.fieldName, tt.args.fieldType, []*analyzer.Validation{validation}) + got, err := gv.BuildValidationCode(tt.args.fieldName, tt.args.fieldType, []*analyzer.Validation{validation}) if err != nil { - t.Errorf("buildValidationCode() error = %v, wantErr %v", err, nil) + t.Errorf("BuildValidationCode() error = %v, wantErr %v", err, nil) return } if got != tt.want { - t.Errorf("buildValidationCode() = %v, want %v", got, tt.want) + t.Errorf("BuildValidationCode() = %v, want %v", got, tt.want) } }) } @@ -506,15 +506,15 @@ errs = append(errs, types.NewValidationError("field must have exactly 3 elements for _, tt := range tests { testName := fmt.Sprintf("validation: %s with %s (%s)", tt.validation, tt.fieldType.ToGenericType(), tt.fieldType.ToNormalizedString()) t.Run(testName, func(t *testing.T) { - gv := genValidations{} + gv := GenValidations{} validation := AssertParserValidation(t, tt.validation) - got, err := gv.buildValidationCode("field", tt.fieldType, []*analyzer.Validation{validation}) + got, err := gv.BuildValidationCode("field", tt.fieldType, []*analyzer.Validation{validation}) if err != nil { - t.Errorf("buildValidationCode() error = %v, wantErr %v", err, nil) + t.Errorf("BuildValidationCode() error = %v, wantErr %v", err, nil) return } if got != tt.want { - t.Errorf("buildValidationCode() = %v, want %v", got, tt.want) + t.Errorf("BuildValidationCode() = %v, want %v", got, tt.want) } }) } diff --git a/internal/codegenerator/codegen.go b/internal/codegenerator/codegen.go index fe581f6..c56991a 100644 --- a/internal/codegenerator/codegen.go +++ b/internal/codegenerator/codegen.go @@ -6,7 +6,7 @@ import ( "github.com/opencodeco/validgen/internal/parser" ) -type genValidations struct { +type GenValidations struct { StructsWithValidation map[string]struct{} Struct *analyzer.Struct } @@ -26,7 +26,7 @@ func GenerateCode(structs []*analyzer.Struct) (map[string]*Pkg, error) { continue } - codeInfo := &genValidations{ + codeInfo := &GenValidations{ StructsWithValidation: structsWithValidation, Struct: st, } From c2142d242c3b735db1a51d7adf83853c4550d486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 26 Oct 2025 13:04:47 -0300 Subject: [PATCH 04/31] feat: testgen bulding validation code tests --- testgen/build_validation_code_test.tpl | 47 ++++++++ testgen/generate_tests.go | 1 + testgen/generate_validation_code_tests.go | 127 +++++++++++++++++++++ testgen/generate_validation_types_tests.go | 4 +- 4 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 testgen/build_validation_code_test.tpl create mode 100644 testgen/generate_validation_code_tests.go diff --git a/testgen/build_validation_code_test.tpl b/testgen/build_validation_code_test.tpl new file mode 100644 index 0000000..c80c514 --- /dev/null +++ b/testgen/build_validation_code_test.tpl @@ -0,0 +1,47 @@ +package codegenerator + +import ( + "testing" + + "github.com/opencodeco/validgen/internal/analyzer" + "github.com/opencodeco/validgen/internal/common" +) + +func {{.FuncName}}(t *testing.T) { + type args struct { + fieldName string + fieldType common.FieldType + fieldValidation string + } + tests := []struct { + name string + args args + want string + }{ +{{range .Tests}} { + name: "{{.TestName}}", + args: args{ + fieldName: "{{.FieldName}}", + fieldType: common.FieldType{ComposedType: "{{.FieldType.ComposedType}}", BaseType: "{{.FieldType.BaseType}}", Size: "{{.FieldType.Size}}"}, + fieldValidation: "{{.Validation}}", + }, + want: `{{.ExpectedCode}}`, + }, +{{end}} + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gv := GenValidations{} + validation := AssertParserValidation(t, tt.args.fieldValidation) + got, err := gv.BuildValidationCode(tt.args.fieldName, tt.args.fieldType, []*analyzer.Validation{validation}) + if err != nil { + t.Errorf("BuildValidationCode() error = %v, wantErr %v", err, nil) + return + } + if got != tt.want { + t.Errorf("BuildValidationCode() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/testgen/generate_tests.go b/testgen/generate_tests.go index 154d76d..3a2775a 100644 --- a/testgen/generate_tests.go +++ b/testgen/generate_tests.go @@ -8,6 +8,7 @@ func main() { fmt.Println("Generating tests files") generateValidationTypesTests() + generateValidationCodeTests() fmt.Println("Generating done") } diff --git a/testgen/generate_validation_code_tests.go b/testgen/generate_validation_code_tests.go new file mode 100644 index 0000000..6eadbcc --- /dev/null +++ b/testgen/generate_validation_code_tests.go @@ -0,0 +1,127 @@ +package main + +import ( + "bytes" + "fmt" + "go/format" + "log" + "os" + "text/template" + + "github.com/opencodeco/validgen/internal/analyzer" + "github.com/opencodeco/validgen/internal/codegenerator" + "github.com/opencodeco/validgen/internal/common" + "golang.org/x/text/cases" + "golang.org/x/text/language" +) + +type ValidationCodeTestCases struct { + FuncName string + Tests []ValidationCodeTestCase +} + +type ValidationCodeTestCase struct { + TestName string + FieldName string + FieldType common.FieldType + Validation string + ExpectedCode string +} + +func generateValidationCodeTests() { + generateValidationCodeTestsFile("build_validation_code_test.tpl", "generated_validation_code_no_pointer_test.go", false) + generateValidationCodeTestsFile("build_validation_code_test.tpl", "generated_validation_code_pointer_test.go", true) +} + +func generateValidationCodeTestsFile(tpl, dest string, pointer bool) { + log.Printf("Generating validation code test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) + + funcName := "TestBuildValidationCode" + if pointer { + funcName += "Pointer" + } + + testCases := ValidationCodeTestCases{ + FuncName: funcName, + } + + for _, typeValidation := range typesValidation { + for _, toGenerate := range typeValidation.testCases { + // Default ("") gen no pointer and pointer test. + if toGenerate.generateFor != "" { + if toGenerate.generateFor == "pointer" && !pointer { + continue + } + if toGenerate.generateFor == "nopointer" && pointer { + continue + } + } + + normalizedType := toGenerate.typeClass + if pointer { + normalizedType = "*" + normalizedType + } + + fieldTypes, _ := common.HelperFromNormalizedToFieldTypes(normalizedType) + for _, fieldType := range fieldTypes { + validation := typeValidation.tag + if typeValidation.argsCount != common.ZeroValue { + validation += "=" + toGenerate.validation + } + testName := fmt.Sprintf("%s_%s_%s", typeValidation.tag, cases.Lower(language.Und).String(fieldType.ToStringName()), validation) + fieldName := "Field" + cases.Title(language.Und).String(typeValidation.tag) + fieldType.ToStringName() + gv := codegenerator.GenValidations{} + parsedValidation, err := analyzer.ParserValidation(validation) + if err != nil { + log.Fatalf("failed to parse validation %q: %v", validation, err) + } + expectedValidationCode, err := gv.BuildValidationCode(fieldName, fieldType, []*analyzer.Validation{parsedValidation}) + if err != nil { + log.Fatalf("failed to build validation code for %q: %v", fieldName, err) + } + + testCases.Tests = append(testCases.Tests, ValidationCodeTestCase{ + TestName: testName, + FieldName: fieldName, + FieldType: fieldType, + Validation: validation, + ExpectedCode: expectedValidationCode, + }) + } + } + } + + if err := testCases.GenerateFile(tpl, dest); err != nil { + log.Fatalf("error generation validation code tests file %s", err) + } + + log.Printf("Generating %s done\n", dest) +} + +func (at *ValidationCodeTestCases) GenerateFile(tplFile, output string) error { + tpl, err := os.ReadFile(tplFile) + if err != nil { + return fmt.Errorf("error reading %s: %s", tplFile, err) + } + + tmpl, err := template.New("ValidationCodeTests").Parse(string(tpl)) + if err != nil { + return err + } + + code := new(bytes.Buffer) + if err := tmpl.Execute(code, at); err != nil { + return err + } + + formattedCode, err := format.Source(code.Bytes()) + if err != nil { + return err + } + + if err := os.WriteFile(output, formattedCode, 0644); err != nil { + return err + } + + return nil +} diff --git a/testgen/generate_validation_types_tests.go b/testgen/generate_validation_types_tests.go index 9b53221..3c84647 100644 --- a/testgen/generate_validation_types_tests.go +++ b/testgen/generate_validation_types_tests.go @@ -34,8 +34,8 @@ type TestCase struct { } func generateValidationTypesTests() { - generateValidationTypesTestsFile("no_pointer_tests.tpl", "generated_no_pointer_tests.go", false) - generateValidationTypesTestsFile("pointer_tests.tpl", "generated_pointer_tests.go", true) + generateValidationTypesTestsFile("no_pointer_tests.tpl", "generated_endtoend_no_pointer_tests.go", false) + generateValidationTypesTestsFile("pointer_tests.tpl", "generated_endtoend_pointer_tests.go", true) } func generateValidationTypesTestsFile(tpl, dest string, pointer bool) { From f6bdb383b08f8b3daf88fe7280bb0dfc60befc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 26 Oct 2025 13:06:25 -0300 Subject: [PATCH 05/31] test: add generated validation code test files --- ...nerated_validation_code_no_pointer_test.go | 3877 ++++++++++++++++ .../generated_validation_code_pointer_test.go | 4045 +++++++++++++++++ 2 files changed, 7922 insertions(+) create mode 100644 internal/codegenerator/generated_validation_code_no_pointer_test.go create mode 100644 internal/codegenerator/generated_validation_code_pointer_test.go diff --git a/internal/codegenerator/generated_validation_code_no_pointer_test.go b/internal/codegenerator/generated_validation_code_no_pointer_test.go new file mode 100644 index 0000000..ed605a7 --- /dev/null +++ b/internal/codegenerator/generated_validation_code_no_pointer_test.go @@ -0,0 +1,3877 @@ +package codegenerator + +import ( + "testing" + + "github.com/opencodeco/validgen/internal/analyzer" + "github.com/opencodeco/validgen/internal/common" +) + +func TestBuildValidationCode(t *testing.T) { + type args struct { + fieldName string + fieldType common.FieldType + fieldValidation string + } + tests := []struct { + name string + args args + want string + }{ + { + name: "email_string_email", + args: args{ + fieldName: "FieldEmailString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "email", + }, + want: `if !(types.IsValidEmail(obj.FieldEmailString)) { +errs = append(errs, types.NewValidationError("FieldEmailString must be a valid email")) +} +`, + }, + { + name: "required_string_required", + args: args{ + fieldName: "FieldRequiredString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredString != "") { +errs = append(errs, types.NewValidationError("FieldRequiredString is required")) +} +`, + }, + { + name: "required_int_required", + args: args{ + fieldName: "FieldRequiredInt", + fieldType: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt is required")) +} +`, + }, + { + name: "required_int8_required", + args: args{ + fieldName: "FieldRequiredInt8", + fieldType: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt8 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8 is required")) +} +`, + }, + { + name: "required_int16_required", + args: args{ + fieldName: "FieldRequiredInt16", + fieldType: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt16 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16 is required")) +} +`, + }, + { + name: "required_int32_required", + args: args{ + fieldName: "FieldRequiredInt32", + fieldType: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt32 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32 is required")) +} +`, + }, + { + name: "required_int64_required", + args: args{ + fieldName: "FieldRequiredInt64", + fieldType: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt64 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64 is required")) +} +`, + }, + { + name: "required_uint_required", + args: args{ + fieldName: "FieldRequiredUint", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint is required")) +} +`, + }, + { + name: "required_uint8_required", + args: args{ + fieldName: "FieldRequiredUint8", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint8 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8 is required")) +} +`, + }, + { + name: "required_uint16_required", + args: args{ + fieldName: "FieldRequiredUint16", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint16 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16 is required")) +} +`, + }, + { + name: "required_uint32_required", + args: args{ + fieldName: "FieldRequiredUint32", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint32 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32 is required")) +} +`, + }, + { + name: "required_uint64_required", + args: args{ + fieldName: "FieldRequiredUint64", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint64 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64 is required")) +} +`, + }, + { + name: "required_float32_required", + args: args{ + fieldName: "FieldRequiredFloat32", + fieldType: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat32 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32 is required")) +} +`, + }, + { + name: "required_float64_required", + args: args{ + fieldName: "FieldRequiredFloat64", + fieldType: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat64 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64 is required")) +} +`, + }, + { + name: "required_bool_required", + args: args{ + fieldName: "FieldRequiredBool", + fieldType: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredBool != false) { +errs = append(errs, types.NewValidationError("FieldRequiredBool is required")) +} +`, + }, + { + name: "required_stringslice_required", + args: args{ + fieldName: "FieldRequiredStringSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredStringSlice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredStringSlice must not be empty")) +} +`, + }, + { + name: "required_intslice_required", + args: args{ + fieldName: "FieldRequiredIntSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredIntSlice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntSlice must not be empty")) +} +`, + }, + { + name: "required_int8slice_required", + args: args{ + fieldName: "FieldRequiredInt8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredInt8Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8Slice must not be empty")) +} +`, + }, + { + name: "required_int16slice_required", + args: args{ + fieldName: "FieldRequiredInt16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredInt16Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16Slice must not be empty")) +} +`, + }, + { + name: "required_int32slice_required", + args: args{ + fieldName: "FieldRequiredInt32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredInt32Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32Slice must not be empty")) +} +`, + }, + { + name: "required_int64slice_required", + args: args{ + fieldName: "FieldRequiredInt64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredInt64Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64Slice must not be empty")) +} +`, + }, + { + name: "required_uintslice_required", + args: args{ + fieldName: "FieldRequiredUintSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUintSlice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintSlice must not be empty")) +} +`, + }, + { + name: "required_uint8slice_required", + args: args{ + fieldName: "FieldRequiredUint8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUint8Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8Slice must not be empty")) +} +`, + }, + { + name: "required_uint16slice_required", + args: args{ + fieldName: "FieldRequiredUint16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUint16Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16Slice must not be empty")) +} +`, + }, + { + name: "required_uint32slice_required", + args: args{ + fieldName: "FieldRequiredUint32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUint32Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32Slice must not be empty")) +} +`, + }, + { + name: "required_uint64slice_required", + args: args{ + fieldName: "FieldRequiredUint64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUint64Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64Slice must not be empty")) +} +`, + }, + { + name: "required_float32slice_required", + args: args{ + fieldName: "FieldRequiredFloat32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredFloat32Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32Slice must not be empty")) +} +`, + }, + { + name: "required_float64slice_required", + args: args{ + fieldName: "FieldRequiredFloat64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredFloat64Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64Slice must not be empty")) +} +`, + }, + { + name: "required_boolslice_required", + args: args{ + fieldName: "FieldRequiredBoolSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredBoolSlice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolSlice must not be empty")) +} +`, + }, + { + name: "required_stringmap_required", + args: args{ + fieldName: "FieldRequiredStringMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredStringMap) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredStringMap must not be empty")) +} +`, + }, + { + name: "required_intmap_required", + args: args{ + fieldName: "FieldRequiredIntMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredIntMap) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntMap must not be empty")) +} +`, + }, + { + name: "required_int8map_required", + args: args{ + fieldName: "FieldRequiredInt8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredInt8Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8Map must not be empty")) +} +`, + }, + { + name: "required_int16map_required", + args: args{ + fieldName: "FieldRequiredInt16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredInt16Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16Map must not be empty")) +} +`, + }, + { + name: "required_int32map_required", + args: args{ + fieldName: "FieldRequiredInt32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredInt32Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32Map must not be empty")) +} +`, + }, + { + name: "required_int64map_required", + args: args{ + fieldName: "FieldRequiredInt64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredInt64Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64Map must not be empty")) +} +`, + }, + { + name: "required_uintmap_required", + args: args{ + fieldName: "FieldRequiredUintMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUintMap) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintMap must not be empty")) +} +`, + }, + { + name: "required_uint8map_required", + args: args{ + fieldName: "FieldRequiredUint8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUint8Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8Map must not be empty")) +} +`, + }, + { + name: "required_uint16map_required", + args: args{ + fieldName: "FieldRequiredUint16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUint16Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16Map must not be empty")) +} +`, + }, + { + name: "required_uint32map_required", + args: args{ + fieldName: "FieldRequiredUint32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUint32Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32Map must not be empty")) +} +`, + }, + { + name: "required_uint64map_required", + args: args{ + fieldName: "FieldRequiredUint64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredUint64Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64Map must not be empty")) +} +`, + }, + { + name: "required_float32map_required", + args: args{ + fieldName: "FieldRequiredFloat32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredFloat32Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32Map must not be empty")) +} +`, + }, + { + name: "required_float64map_required", + args: args{ + fieldName: "FieldRequiredFloat64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredFloat64Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64Map must not be empty")) +} +`, + }, + { + name: "required_boolmap_required", + args: args{ + fieldName: "FieldRequiredBoolMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + fieldValidation: "required", + }, + want: `if !(len(obj.FieldRequiredBoolMap) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolMap must not be empty")) +} +`, + }, + { + name: "eq_string_eq=abcde", + args: args{ + fieldName: "FieldEqString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "eq=abcde", + }, + want: `if !(obj.FieldEqString == "abcde") { +errs = append(errs, types.NewValidationError("FieldEqString must be equal to 'abcde'")) +} +`, + }, + { + name: "eq_int_eq=32", + args: args{ + fieldName: "FieldEqInt", + fieldType: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqInt == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt must be equal to 32")) +} +`, + }, + { + name: "eq_int8_eq=32", + args: args{ + fieldName: "FieldEqInt8", + fieldType: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqInt8 == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt8 must be equal to 32")) +} +`, + }, + { + name: "eq_int16_eq=32", + args: args{ + fieldName: "FieldEqInt16", + fieldType: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqInt16 == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt16 must be equal to 32")) +} +`, + }, + { + name: "eq_int32_eq=32", + args: args{ + fieldName: "FieldEqInt32", + fieldType: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqInt32 == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt32 must be equal to 32")) +} +`, + }, + { + name: "eq_int64_eq=32", + args: args{ + fieldName: "FieldEqInt64", + fieldType: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqInt64 == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt64 must be equal to 32")) +} +`, + }, + { + name: "eq_uint_eq=32", + args: args{ + fieldName: "FieldEqUint", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUint == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint must be equal to 32")) +} +`, + }, + { + name: "eq_uint8_eq=32", + args: args{ + fieldName: "FieldEqUint8", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUint8 == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint8 must be equal to 32")) +} +`, + }, + { + name: "eq_uint16_eq=32", + args: args{ + fieldName: "FieldEqUint16", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUint16 == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint16 must be equal to 32")) +} +`, + }, + { + name: "eq_uint32_eq=32", + args: args{ + fieldName: "FieldEqUint32", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUint32 == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint32 must be equal to 32")) +} +`, + }, + { + name: "eq_uint64_eq=32", + args: args{ + fieldName: "FieldEqUint64", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUint64 == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint64 must be equal to 32")) +} +`, + }, + { + name: "eq_float32_eq=12.34", + args: args{ + fieldName: "FieldEqFloat32", + fieldType: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + fieldValidation: "eq=12.34", + }, + want: `if !(obj.FieldEqFloat32 == 12.34) { +errs = append(errs, types.NewValidationError("FieldEqFloat32 must be equal to 12.34")) +} +`, + }, + { + name: "eq_float64_eq=12.34", + args: args{ + fieldName: "FieldEqFloat64", + fieldType: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + fieldValidation: "eq=12.34", + }, + want: `if !(obj.FieldEqFloat64 == 12.34) { +errs = append(errs, types.NewValidationError("FieldEqFloat64 must be equal to 12.34")) +} +`, + }, + { + name: "eq_bool_eq=true", + args: args{ + fieldName: "FieldEqBool", + fieldType: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + fieldValidation: "eq=true", + }, + want: `if !(obj.FieldEqBool == true) { +errs = append(errs, types.NewValidationError("FieldEqBool must be equal to true")) +} +`, + }, + { + name: "neq_string_neq=abcde", + args: args{ + fieldName: "FieldNeqString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "neq=abcde", + }, + want: `if !(obj.FieldNeqString != "abcde") { +errs = append(errs, types.NewValidationError("FieldNeqString must not be equal to 'abcde'")) +} +`, + }, + { + name: "neq_int_neq=32", + args: args{ + fieldName: "FieldNeqInt", + fieldType: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqInt != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt must not be equal to 32")) +} +`, + }, + { + name: "neq_int8_neq=32", + args: args{ + fieldName: "FieldNeqInt8", + fieldType: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqInt8 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt8 must not be equal to 32")) +} +`, + }, + { + name: "neq_int16_neq=32", + args: args{ + fieldName: "FieldNeqInt16", + fieldType: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqInt16 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt16 must not be equal to 32")) +} +`, + }, + { + name: "neq_int32_neq=32", + args: args{ + fieldName: "FieldNeqInt32", + fieldType: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqInt32 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt32 must not be equal to 32")) +} +`, + }, + { + name: "neq_int64_neq=32", + args: args{ + fieldName: "FieldNeqInt64", + fieldType: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqInt64 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt64 must not be equal to 32")) +} +`, + }, + { + name: "neq_uint_neq=32", + args: args{ + fieldName: "FieldNeqUint", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUint != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint must not be equal to 32")) +} +`, + }, + { + name: "neq_uint8_neq=32", + args: args{ + fieldName: "FieldNeqUint8", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUint8 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint8 must not be equal to 32")) +} +`, + }, + { + name: "neq_uint16_neq=32", + args: args{ + fieldName: "FieldNeqUint16", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUint16 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint16 must not be equal to 32")) +} +`, + }, + { + name: "neq_uint32_neq=32", + args: args{ + fieldName: "FieldNeqUint32", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUint32 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint32 must not be equal to 32")) +} +`, + }, + { + name: "neq_uint64_neq=32", + args: args{ + fieldName: "FieldNeqUint64", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUint64 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint64 must not be equal to 32")) +} +`, + }, + { + name: "neq_float32_neq=12.34", + args: args{ + fieldName: "FieldNeqFloat32", + fieldType: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + fieldValidation: "neq=12.34", + }, + want: `if !(obj.FieldNeqFloat32 != 12.34) { +errs = append(errs, types.NewValidationError("FieldNeqFloat32 must not be equal to 12.34")) +} +`, + }, + { + name: "neq_float64_neq=12.34", + args: args{ + fieldName: "FieldNeqFloat64", + fieldType: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + fieldValidation: "neq=12.34", + }, + want: `if !(obj.FieldNeqFloat64 != 12.34) { +errs = append(errs, types.NewValidationError("FieldNeqFloat64 must not be equal to 12.34")) +} +`, + }, + { + name: "neq_bool_neq=true", + args: args{ + fieldName: "FieldNeqBool", + fieldType: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + fieldValidation: "neq=true", + }, + want: `if !(obj.FieldNeqBool != true) { +errs = append(errs, types.NewValidationError("FieldNeqBool must not be equal to true")) +} +`, + }, + { + name: "gt_int_gt=32", + args: args{ + fieldName: "FieldGtInt", + fieldType: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtInt > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt must be > 32")) +} +`, + }, + { + name: "gt_int8_gt=32", + args: args{ + fieldName: "FieldGtInt8", + fieldType: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtInt8 > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt8 must be > 32")) +} +`, + }, + { + name: "gt_int16_gt=32", + args: args{ + fieldName: "FieldGtInt16", + fieldType: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtInt16 > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt16 must be > 32")) +} +`, + }, + { + name: "gt_int32_gt=32", + args: args{ + fieldName: "FieldGtInt32", + fieldType: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtInt32 > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt32 must be > 32")) +} +`, + }, + { + name: "gt_int64_gt=32", + args: args{ + fieldName: "FieldGtInt64", + fieldType: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtInt64 > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt64 must be > 32")) +} +`, + }, + { + name: "gt_uint_gt=32", + args: args{ + fieldName: "FieldGtUint", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUint > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint must be > 32")) +} +`, + }, + { + name: "gt_uint8_gt=32", + args: args{ + fieldName: "FieldGtUint8", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUint8 > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint8 must be > 32")) +} +`, + }, + { + name: "gt_uint16_gt=32", + args: args{ + fieldName: "FieldGtUint16", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUint16 > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint16 must be > 32")) +} +`, + }, + { + name: "gt_uint32_gt=32", + args: args{ + fieldName: "FieldGtUint32", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUint32 > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint32 must be > 32")) +} +`, + }, + { + name: "gt_uint64_gt=32", + args: args{ + fieldName: "FieldGtUint64", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUint64 > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint64 must be > 32")) +} +`, + }, + { + name: "gt_float32_gt=12.34", + args: args{ + fieldName: "FieldGtFloat32", + fieldType: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + fieldValidation: "gt=12.34", + }, + want: `if !(obj.FieldGtFloat32 > 12.34) { +errs = append(errs, types.NewValidationError("FieldGtFloat32 must be > 12.34")) +} +`, + }, + { + name: "gt_float64_gt=12.34", + args: args{ + fieldName: "FieldGtFloat64", + fieldType: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + fieldValidation: "gt=12.34", + }, + want: `if !(obj.FieldGtFloat64 > 12.34) { +errs = append(errs, types.NewValidationError("FieldGtFloat64 must be > 12.34")) +} +`, + }, + { + name: "gte_int_gte=32", + args: args{ + fieldName: "FieldGteInt", + fieldType: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteInt >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt must be >= 32")) +} +`, + }, + { + name: "gte_int8_gte=32", + args: args{ + fieldName: "FieldGteInt8", + fieldType: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteInt8 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt8 must be >= 32")) +} +`, + }, + { + name: "gte_int16_gte=32", + args: args{ + fieldName: "FieldGteInt16", + fieldType: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteInt16 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt16 must be >= 32")) +} +`, + }, + { + name: "gte_int32_gte=32", + args: args{ + fieldName: "FieldGteInt32", + fieldType: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteInt32 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt32 must be >= 32")) +} +`, + }, + { + name: "gte_int64_gte=32", + args: args{ + fieldName: "FieldGteInt64", + fieldType: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteInt64 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt64 must be >= 32")) +} +`, + }, + { + name: "gte_uint_gte=32", + args: args{ + fieldName: "FieldGteUint", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUint >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint must be >= 32")) +} +`, + }, + { + name: "gte_uint8_gte=32", + args: args{ + fieldName: "FieldGteUint8", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUint8 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint8 must be >= 32")) +} +`, + }, + { + name: "gte_uint16_gte=32", + args: args{ + fieldName: "FieldGteUint16", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUint16 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint16 must be >= 32")) +} +`, + }, + { + name: "gte_uint32_gte=32", + args: args{ + fieldName: "FieldGteUint32", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUint32 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint32 must be >= 32")) +} +`, + }, + { + name: "gte_uint64_gte=32", + args: args{ + fieldName: "FieldGteUint64", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUint64 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint64 must be >= 32")) +} +`, + }, + { + name: "gte_float32_gte=12.34", + args: args{ + fieldName: "FieldGteFloat32", + fieldType: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + fieldValidation: "gte=12.34", + }, + want: `if !(obj.FieldGteFloat32 >= 12.34) { +errs = append(errs, types.NewValidationError("FieldGteFloat32 must be >= 12.34")) +} +`, + }, + { + name: "gte_float64_gte=12.34", + args: args{ + fieldName: "FieldGteFloat64", + fieldType: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + fieldValidation: "gte=12.34", + }, + want: `if !(obj.FieldGteFloat64 >= 12.34) { +errs = append(errs, types.NewValidationError("FieldGteFloat64 must be >= 12.34")) +} +`, + }, + { + name: "lt_int_lt=32", + args: args{ + fieldName: "FieldLtInt", + fieldType: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtInt < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt must be < 32")) +} +`, + }, + { + name: "lt_int8_lt=32", + args: args{ + fieldName: "FieldLtInt8", + fieldType: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtInt8 < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt8 must be < 32")) +} +`, + }, + { + name: "lt_int16_lt=32", + args: args{ + fieldName: "FieldLtInt16", + fieldType: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtInt16 < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt16 must be < 32")) +} +`, + }, + { + name: "lt_int32_lt=32", + args: args{ + fieldName: "FieldLtInt32", + fieldType: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtInt32 < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt32 must be < 32")) +} +`, + }, + { + name: "lt_int64_lt=32", + args: args{ + fieldName: "FieldLtInt64", + fieldType: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtInt64 < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt64 must be < 32")) +} +`, + }, + { + name: "lt_uint_lt=32", + args: args{ + fieldName: "FieldLtUint", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUint < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint must be < 32")) +} +`, + }, + { + name: "lt_uint8_lt=32", + args: args{ + fieldName: "FieldLtUint8", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUint8 < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint8 must be < 32")) +} +`, + }, + { + name: "lt_uint16_lt=32", + args: args{ + fieldName: "FieldLtUint16", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUint16 < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint16 must be < 32")) +} +`, + }, + { + name: "lt_uint32_lt=32", + args: args{ + fieldName: "FieldLtUint32", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUint32 < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint32 must be < 32")) +} +`, + }, + { + name: "lt_uint64_lt=32", + args: args{ + fieldName: "FieldLtUint64", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUint64 < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint64 must be < 32")) +} +`, + }, + { + name: "lt_float32_lt=12.34", + args: args{ + fieldName: "FieldLtFloat32", + fieldType: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + fieldValidation: "lt=12.34", + }, + want: `if !(obj.FieldLtFloat32 < 12.34) { +errs = append(errs, types.NewValidationError("FieldLtFloat32 must be < 12.34")) +} +`, + }, + { + name: "lt_float64_lt=12.34", + args: args{ + fieldName: "FieldLtFloat64", + fieldType: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + fieldValidation: "lt=12.34", + }, + want: `if !(obj.FieldLtFloat64 < 12.34) { +errs = append(errs, types.NewValidationError("FieldLtFloat64 must be < 12.34")) +} +`, + }, + { + name: "lte_int_lte=32", + args: args{ + fieldName: "FieldLteInt", + fieldType: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteInt <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt must be <= 32")) +} +`, + }, + { + name: "lte_int8_lte=32", + args: args{ + fieldName: "FieldLteInt8", + fieldType: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteInt8 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt8 must be <= 32")) +} +`, + }, + { + name: "lte_int16_lte=32", + args: args{ + fieldName: "FieldLteInt16", + fieldType: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteInt16 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt16 must be <= 32")) +} +`, + }, + { + name: "lte_int32_lte=32", + args: args{ + fieldName: "FieldLteInt32", + fieldType: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteInt32 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt32 must be <= 32")) +} +`, + }, + { + name: "lte_int64_lte=32", + args: args{ + fieldName: "FieldLteInt64", + fieldType: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteInt64 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt64 must be <= 32")) +} +`, + }, + { + name: "lte_uint_lte=32", + args: args{ + fieldName: "FieldLteUint", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUint <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint must be <= 32")) +} +`, + }, + { + name: "lte_uint8_lte=32", + args: args{ + fieldName: "FieldLteUint8", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUint8 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint8 must be <= 32")) +} +`, + }, + { + name: "lte_uint16_lte=32", + args: args{ + fieldName: "FieldLteUint16", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUint16 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint16 must be <= 32")) +} +`, + }, + { + name: "lte_uint32_lte=32", + args: args{ + fieldName: "FieldLteUint32", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUint32 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint32 must be <= 32")) +} +`, + }, + { + name: "lte_uint64_lte=32", + args: args{ + fieldName: "FieldLteUint64", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUint64 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint64 must be <= 32")) +} +`, + }, + { + name: "lte_float32_lte=12.34", + args: args{ + fieldName: "FieldLteFloat32", + fieldType: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + fieldValidation: "lte=12.34", + }, + want: `if !(obj.FieldLteFloat32 <= 12.34) { +errs = append(errs, types.NewValidationError("FieldLteFloat32 must be <= 12.34")) +} +`, + }, + { + name: "lte_float64_lte=12.34", + args: args{ + fieldName: "FieldLteFloat64", + fieldType: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + fieldValidation: "lte=12.34", + }, + want: `if !(obj.FieldLteFloat64 <= 12.34) { +errs = append(errs, types.NewValidationError("FieldLteFloat64 must be <= 12.34")) +} +`, + }, + { + name: "min_string_min=5", + args: args{ + fieldName: "FieldMinString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "min=5", + }, + want: `if !(len(obj.FieldMinString) >= 5) { +errs = append(errs, types.NewValidationError("FieldMinString length must be >= 5")) +} +`, + }, + { + name: "min_stringslice_min=2", + args: args{ + fieldName: "FieldMinStringSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinStringSlice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinStringSlice must have at least 2 elements")) +} +`, + }, + { + name: "min_intslice_min=2", + args: args{ + fieldName: "FieldMinIntSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinIntSlice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinIntSlice must have at least 2 elements")) +} +`, + }, + { + name: "min_int8slice_min=2", + args: args{ + fieldName: "FieldMinInt8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinInt8Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt8Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_int16slice_min=2", + args: args{ + fieldName: "FieldMinInt16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinInt16Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt16Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_int32slice_min=2", + args: args{ + fieldName: "FieldMinInt32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinInt32Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt32Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_int64slice_min=2", + args: args{ + fieldName: "FieldMinInt64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinInt64Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt64Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_uintslice_min=2", + args: args{ + fieldName: "FieldMinUintSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUintSlice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUintSlice must have at least 2 elements")) +} +`, + }, + { + name: "min_uint8slice_min=2", + args: args{ + fieldName: "FieldMinUint8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUint8Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint8Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_uint16slice_min=2", + args: args{ + fieldName: "FieldMinUint16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUint16Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint16Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_uint32slice_min=2", + args: args{ + fieldName: "FieldMinUint32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUint32Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint32Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_uint64slice_min=2", + args: args{ + fieldName: "FieldMinUint64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUint64Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint64Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_float32slice_min=2", + args: args{ + fieldName: "FieldMinFloat32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinFloat32Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat32Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_float64slice_min=2", + args: args{ + fieldName: "FieldMinFloat64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinFloat64Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat64Slice must have at least 2 elements")) +} +`, + }, + { + name: "min_boolslice_min=2", + args: args{ + fieldName: "FieldMinBoolSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinBoolSlice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinBoolSlice must have at least 2 elements")) +} +`, + }, + { + name: "min_stringmap_min=2", + args: args{ + fieldName: "FieldMinStringMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinStringMap) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinStringMap must have at least 2 elements")) +} +`, + }, + { + name: "min_intmap_min=2", + args: args{ + fieldName: "FieldMinIntMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinIntMap) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinIntMap must have at least 2 elements")) +} +`, + }, + { + name: "min_int8map_min=2", + args: args{ + fieldName: "FieldMinInt8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinInt8Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt8Map must have at least 2 elements")) +} +`, + }, + { + name: "min_int16map_min=2", + args: args{ + fieldName: "FieldMinInt16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinInt16Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt16Map must have at least 2 elements")) +} +`, + }, + { + name: "min_int32map_min=2", + args: args{ + fieldName: "FieldMinInt32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinInt32Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt32Map must have at least 2 elements")) +} +`, + }, + { + name: "min_int64map_min=2", + args: args{ + fieldName: "FieldMinInt64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinInt64Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt64Map must have at least 2 elements")) +} +`, + }, + { + name: "min_uintmap_min=2", + args: args{ + fieldName: "FieldMinUintMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUintMap) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUintMap must have at least 2 elements")) +} +`, + }, + { + name: "min_uint8map_min=2", + args: args{ + fieldName: "FieldMinUint8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUint8Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint8Map must have at least 2 elements")) +} +`, + }, + { + name: "min_uint16map_min=2", + args: args{ + fieldName: "FieldMinUint16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUint16Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint16Map must have at least 2 elements")) +} +`, + }, + { + name: "min_uint32map_min=2", + args: args{ + fieldName: "FieldMinUint32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUint32Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint32Map must have at least 2 elements")) +} +`, + }, + { + name: "min_uint64map_min=2", + args: args{ + fieldName: "FieldMinUint64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinUint64Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint64Map must have at least 2 elements")) +} +`, + }, + { + name: "min_float32map_min=2", + args: args{ + fieldName: "FieldMinFloat32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinFloat32Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat32Map must have at least 2 elements")) +} +`, + }, + { + name: "min_float64map_min=2", + args: args{ + fieldName: "FieldMinFloat64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinFloat64Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat64Map must have at least 2 elements")) +} +`, + }, + { + name: "min_boolmap_min=2", + args: args{ + fieldName: "FieldMinBoolMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(len(obj.FieldMinBoolMap) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinBoolMap must have at least 2 elements")) +} +`, + }, + { + name: "max_string_max=3", + args: args{ + fieldName: "FieldMaxString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "max=3", + }, + want: `if !(len(obj.FieldMaxString) <= 3) { +errs = append(errs, types.NewValidationError("FieldMaxString length must be <= 3")) +} +`, + }, + { + name: "max_stringslice_max=2", + args: args{ + fieldName: "FieldMaxStringSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxStringSlice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxStringSlice must have at most 2 elements")) +} +`, + }, + { + name: "max_intslice_max=2", + args: args{ + fieldName: "FieldMaxIntSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxIntSlice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxIntSlice must have at most 2 elements")) +} +`, + }, + { + name: "max_int8slice_max=2", + args: args{ + fieldName: "FieldMaxInt8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxInt8Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt8Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_int16slice_max=2", + args: args{ + fieldName: "FieldMaxInt16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxInt16Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt16Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_int32slice_max=2", + args: args{ + fieldName: "FieldMaxInt32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxInt32Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt32Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_int64slice_max=2", + args: args{ + fieldName: "FieldMaxInt64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxInt64Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt64Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_uintslice_max=2", + args: args{ + fieldName: "FieldMaxUintSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUintSlice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUintSlice must have at most 2 elements")) +} +`, + }, + { + name: "max_uint8slice_max=2", + args: args{ + fieldName: "FieldMaxUint8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUint8Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint8Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_uint16slice_max=2", + args: args{ + fieldName: "FieldMaxUint16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUint16Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint16Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_uint32slice_max=2", + args: args{ + fieldName: "FieldMaxUint32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUint32Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint32Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_uint64slice_max=2", + args: args{ + fieldName: "FieldMaxUint64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUint64Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint64Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_float32slice_max=2", + args: args{ + fieldName: "FieldMaxFloat32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxFloat32Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat32Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_float64slice_max=2", + args: args{ + fieldName: "FieldMaxFloat64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxFloat64Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat64Slice must have at most 2 elements")) +} +`, + }, + { + name: "max_boolslice_max=2", + args: args{ + fieldName: "FieldMaxBoolSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxBoolSlice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxBoolSlice must have at most 2 elements")) +} +`, + }, + { + name: "max_stringmap_max=2", + args: args{ + fieldName: "FieldMaxStringMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxStringMap) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxStringMap must have at most 2 elements")) +} +`, + }, + { + name: "max_intmap_max=2", + args: args{ + fieldName: "FieldMaxIntMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxIntMap) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxIntMap must have at most 2 elements")) +} +`, + }, + { + name: "max_int8map_max=2", + args: args{ + fieldName: "FieldMaxInt8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxInt8Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt8Map must have at most 2 elements")) +} +`, + }, + { + name: "max_int16map_max=2", + args: args{ + fieldName: "FieldMaxInt16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxInt16Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt16Map must have at most 2 elements")) +} +`, + }, + { + name: "max_int32map_max=2", + args: args{ + fieldName: "FieldMaxInt32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxInt32Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt32Map must have at most 2 elements")) +} +`, + }, + { + name: "max_int64map_max=2", + args: args{ + fieldName: "FieldMaxInt64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxInt64Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt64Map must have at most 2 elements")) +} +`, + }, + { + name: "max_uintmap_max=2", + args: args{ + fieldName: "FieldMaxUintMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUintMap) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUintMap must have at most 2 elements")) +} +`, + }, + { + name: "max_uint8map_max=2", + args: args{ + fieldName: "FieldMaxUint8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUint8Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint8Map must have at most 2 elements")) +} +`, + }, + { + name: "max_uint16map_max=2", + args: args{ + fieldName: "FieldMaxUint16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUint16Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint16Map must have at most 2 elements")) +} +`, + }, + { + name: "max_uint32map_max=2", + args: args{ + fieldName: "FieldMaxUint32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUint32Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint32Map must have at most 2 elements")) +} +`, + }, + { + name: "max_uint64map_max=2", + args: args{ + fieldName: "FieldMaxUint64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxUint64Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint64Map must have at most 2 elements")) +} +`, + }, + { + name: "max_float32map_max=2", + args: args{ + fieldName: "FieldMaxFloat32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxFloat32Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat32Map must have at most 2 elements")) +} +`, + }, + { + name: "max_float64map_max=2", + args: args{ + fieldName: "FieldMaxFloat64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(len(obj.FieldMaxFloat64Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat64Map must have at most 2 elements")) +} +`, + }, + { + name: "max_boolmap_max=1", + args: args{ + fieldName: "FieldMaxBoolMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + fieldValidation: "max=1", + }, + want: `if !(len(obj.FieldMaxBoolMap) <= 1) { +errs = append(errs, types.NewValidationError("FieldMaxBoolMap must have at most 1 elements")) +} +`, + }, + { + name: "eq_ignore_case_string_eq_ignore_case=abcde", + args: args{ + fieldName: "FieldEq_ignore_caseString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "eq_ignore_case=abcde", + }, + want: `if !(types.EqualFold(obj.FieldEq_ignore_caseString, "abcde")) { +errs = append(errs, types.NewValidationError("FieldEq_ignore_caseString must be equal to 'abcde'")) +} +`, + }, + { + name: "neq_ignore_case_string_neq_ignore_case=abcde", + args: args{ + fieldName: "FieldNeq_ignore_caseString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "neq_ignore_case=abcde", + }, + want: `if !(!types.EqualFold(obj.FieldNeq_ignore_caseString, "abcde")) { +errs = append(errs, types.NewValidationError("FieldNeq_ignore_caseString must not be equal to 'abcde'")) +} +`, + }, + { + name: "len_string_len=2", + args: args{ + fieldName: "FieldLenString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenString) == 2) { +errs = append(errs, types.NewValidationError("FieldLenString length must be 2")) +} +`, + }, + { + name: "len_stringslice_len=2", + args: args{ + fieldName: "FieldLenStringSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenStringSlice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringSlice must have exactly 2 elements")) +} +`, + }, + { + name: "len_intslice_len=2", + args: args{ + fieldName: "FieldLenIntSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenIntSlice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenIntSlice must have exactly 2 elements")) +} +`, + }, + { + name: "len_int8slice_len=2", + args: args{ + fieldName: "FieldLenInt8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenInt8Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt8Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_int16slice_len=2", + args: args{ + fieldName: "FieldLenInt16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenInt16Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt16Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_int32slice_len=2", + args: args{ + fieldName: "FieldLenInt32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenInt32Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt32Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_int64slice_len=2", + args: args{ + fieldName: "FieldLenInt64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenInt64Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt64Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_uintslice_len=2", + args: args{ + fieldName: "FieldLenUintSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUintSlice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUintSlice must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint8slice_len=2", + args: args{ + fieldName: "FieldLenUint8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUint8Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint8Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint16slice_len=2", + args: args{ + fieldName: "FieldLenUint16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUint16Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint16Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint32slice_len=2", + args: args{ + fieldName: "FieldLenUint32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUint32Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint32Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint64slice_len=2", + args: args{ + fieldName: "FieldLenUint64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUint64Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint64Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_float32slice_len=2", + args: args{ + fieldName: "FieldLenFloat32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenFloat32Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat32Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_float64slice_len=2", + args: args{ + fieldName: "FieldLenFloat64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenFloat64Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat64Slice must have exactly 2 elements")) +} +`, + }, + { + name: "len_boolslice_len=2", + args: args{ + fieldName: "FieldLenBoolSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenBoolSlice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenBoolSlice must have exactly 2 elements")) +} +`, + }, + { + name: "len_stringmap_len=2", + args: args{ + fieldName: "FieldLenStringMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenStringMap) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringMap must have exactly 2 elements")) +} +`, + }, + { + name: "len_intmap_len=2", + args: args{ + fieldName: "FieldLenIntMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenIntMap) == 2) { +errs = append(errs, types.NewValidationError("FieldLenIntMap must have exactly 2 elements")) +} +`, + }, + { + name: "len_int8map_len=2", + args: args{ + fieldName: "FieldLenInt8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenInt8Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt8Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_int16map_len=2", + args: args{ + fieldName: "FieldLenInt16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenInt16Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt16Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_int32map_len=2", + args: args{ + fieldName: "FieldLenInt32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenInt32Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt32Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_int64map_len=2", + args: args{ + fieldName: "FieldLenInt64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenInt64Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt64Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_uintmap_len=2", + args: args{ + fieldName: "FieldLenUintMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUintMap) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUintMap must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint8map_len=2", + args: args{ + fieldName: "FieldLenUint8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUint8Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint8Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint16map_len=2", + args: args{ + fieldName: "FieldLenUint16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUint16Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint16Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint32map_len=2", + args: args{ + fieldName: "FieldLenUint32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUint32Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint32Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint64map_len=2", + args: args{ + fieldName: "FieldLenUint64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenUint64Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint64Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_float32map_len=2", + args: args{ + fieldName: "FieldLenFloat32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenFloat32Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat32Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_float64map_len=2", + args: args{ + fieldName: "FieldLenFloat64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenFloat64Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat64Map must have exactly 2 elements")) +} +`, + }, + { + name: "len_boolmap_len=2", + args: args{ + fieldName: "FieldLenBoolMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(len(obj.FieldLenBoolMap) == 2) { +errs = append(errs, types.NewValidationError("FieldLenBoolMap must have exactly 2 elements")) +} +`, + }, + { + name: "in_string_in=ab cd ef", + args: args{ + fieldName: "FieldInString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "in=ab cd ef", + }, + want: `if !(obj.FieldInString == "ab" || obj.FieldInString == "cd" || obj.FieldInString == "ef") { +errs = append(errs, types.NewValidationError("FieldInString must be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "in_int_in=12 34 56", + args: args{ + fieldName: "FieldInInt", + fieldType: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt == 12 || obj.FieldInInt == 34 || obj.FieldInInt == 56) { +errs = append(errs, types.NewValidationError("FieldInInt must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int8_in=12 34 56", + args: args{ + fieldName: "FieldInInt8", + fieldType: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt8 == 12 || obj.FieldInInt8 == 34 || obj.FieldInInt8 == 56) { +errs = append(errs, types.NewValidationError("FieldInInt8 must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int16_in=12 34 56", + args: args{ + fieldName: "FieldInInt16", + fieldType: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt16 == 12 || obj.FieldInInt16 == 34 || obj.FieldInInt16 == 56) { +errs = append(errs, types.NewValidationError("FieldInInt16 must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int32_in=12 34 56", + args: args{ + fieldName: "FieldInInt32", + fieldType: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt32 == 12 || obj.FieldInInt32 == 34 || obj.FieldInInt32 == 56) { +errs = append(errs, types.NewValidationError("FieldInInt32 must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int64_in=12 34 56", + args: args{ + fieldName: "FieldInInt64", + fieldType: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt64 == 12 || obj.FieldInInt64 == 34 || obj.FieldInInt64 == 56) { +errs = append(errs, types.NewValidationError("FieldInInt64 must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint_in=12 34 56", + args: args{ + fieldName: "FieldInUint", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint == 12 || obj.FieldInUint == 34 || obj.FieldInUint == 56) { +errs = append(errs, types.NewValidationError("FieldInUint must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint8_in=12 34 56", + args: args{ + fieldName: "FieldInUint8", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint8 == 12 || obj.FieldInUint8 == 34 || obj.FieldInUint8 == 56) { +errs = append(errs, types.NewValidationError("FieldInUint8 must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint16_in=12 34 56", + args: args{ + fieldName: "FieldInUint16", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint16 == 12 || obj.FieldInUint16 == 34 || obj.FieldInUint16 == 56) { +errs = append(errs, types.NewValidationError("FieldInUint16 must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint32_in=12 34 56", + args: args{ + fieldName: "FieldInUint32", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint32 == 12 || obj.FieldInUint32 == 34 || obj.FieldInUint32 == 56) { +errs = append(errs, types.NewValidationError("FieldInUint32 must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint64_in=12 34 56", + args: args{ + fieldName: "FieldInUint64", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint64 == 12 || obj.FieldInUint64 == 34 || obj.FieldInUint64 == 56) { +errs = append(errs, types.NewValidationError("FieldInUint64 must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_float32_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat32", + fieldType: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(obj.FieldInFloat32 == 11.11 || obj.FieldInFloat32 == 22.22 || obj.FieldInFloat32 == 33.33) { +errs = append(errs, types.NewValidationError("FieldInFloat32 must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_float64_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat64", + fieldType: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(obj.FieldInFloat64 == 11.11 || obj.FieldInFloat64 == 22.22 || obj.FieldInFloat64 == 33.33) { +errs = append(errs, types.NewValidationError("FieldInFloat64 must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_bool_in=true", + args: args{ + fieldName: "FieldInBool", + fieldType: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + fieldValidation: "in=true", + }, + want: `if !(obj.FieldInBool == true) { +errs = append(errs, types.NewValidationError("FieldInBool must be one of 'true'")) +} +`, + }, + { + name: "in_stringslice_in=ab cd ef", + args: args{ + fieldName: "FieldInStringSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + fieldValidation: "in=ab cd ef", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInStringSlice, []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldInStringSlice elements must be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "in_intslice_in=12 34 56", + args: args{ + fieldName: "FieldInIntSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInIntSlice, []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInIntSlice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int8slice_in=12 34 56", + args: args{ + fieldName: "FieldInInt8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInInt8Slice, []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt8Slice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int16slice_in=12 34 56", + args: args{ + fieldName: "FieldInInt16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInInt16Slice, []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt16Slice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int32slice_in=12 34 56", + args: args{ + fieldName: "FieldInInt32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInInt32Slice, []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt32Slice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int64slice_in=12 34 56", + args: args{ + fieldName: "FieldInInt64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInInt64Slice, []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt64Slice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uintslice_in=12 34 56", + args: args{ + fieldName: "FieldInUintSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUintSlice, []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUintSlice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint8slice_in=12 34 56", + args: args{ + fieldName: "FieldInUint8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUint8Slice, []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint8Slice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint16slice_in=12 34 56", + args: args{ + fieldName: "FieldInUint16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUint16Slice, []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint16Slice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint32slice_in=12 34 56", + args: args{ + fieldName: "FieldInUint32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUint32Slice, []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint32Slice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint64slice_in=12 34 56", + args: args{ + fieldName: "FieldInUint64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUint64Slice, []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint64Slice elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_float32slice_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInFloat32Slice, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32Slice elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_float64slice_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInFloat64Slice, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64Slice elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_boolslice_in=true", + args: args{ + fieldName: "FieldInBoolSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + fieldValidation: "in=true", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInBoolSlice, []bool{true})) { +errs = append(errs, types.NewValidationError("FieldInBoolSlice elements must be one of 'true'")) +} +`, + }, + { + name: "in_stringarray_in=ab cd ef", + args: args{ + fieldName: "FieldInStringArray", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "string", Size: "3"}, + fieldValidation: "in=ab cd ef", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInStringArray[:], []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldInStringArray elements must be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "in_intarray_in=12 34 56", + args: args{ + fieldName: "FieldInIntArray", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInIntArray[:], []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInIntArray elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int8array_in=12 34 56", + args: args{ + fieldName: "FieldInInt8Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int8", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInInt8Array[:], []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt8Array elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int16array_in=12 34 56", + args: args{ + fieldName: "FieldInInt16Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int16", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInInt16Array[:], []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt16Array elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int32array_in=12 34 56", + args: args{ + fieldName: "FieldInInt32Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int32", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInInt32Array[:], []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt32Array elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int64array_in=12 34 56", + args: args{ + fieldName: "FieldInInt64Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int64", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInInt64Array[:], []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt64Array elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uintarray_in=12 34 56", + args: args{ + fieldName: "FieldInUintArray", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUintArray[:], []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUintArray elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint8array_in=12 34 56", + args: args{ + fieldName: "FieldInUint8Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint8", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUint8Array[:], []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint8Array elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint16array_in=12 34 56", + args: args{ + fieldName: "FieldInUint16Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint16", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUint16Array[:], []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint16Array elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint32array_in=12 34 56", + args: args{ + fieldName: "FieldInUint32Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint32", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUint32Array[:], []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint32Array elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint64array_in=12 34 56", + args: args{ + fieldName: "FieldInUint64Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint64", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInUint64Array[:], []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint64Array elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_float32array_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat32Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "float32", Size: "3"}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInFloat32Array[:], []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32Array elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_float64array_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat64Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "float64", Size: "3"}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInFloat64Array[:], []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64Array elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_boolarray_in=true", + args: args{ + fieldName: "FieldInBoolArray", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "bool", Size: "3"}, + fieldValidation: "in=true", + }, + want: `if !(types.SliceOnlyContains(obj.FieldInBoolArray[:], []bool{true})) { +errs = append(errs, types.NewValidationError("FieldInBoolArray elements must be one of 'true'")) +} +`, + }, + { + name: "in_stringmap_in=a b c", + args: args{ + fieldName: "FieldInStringMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + fieldValidation: "in=a b c", + }, + want: `if !(types.MapOnlyContains(obj.FieldInStringMap, []string{"a", "b", "c"})) { +errs = append(errs, types.NewValidationError("FieldInStringMap elements must be one of 'a' 'b' 'c'")) +} +`, + }, + { + name: "in_intmap_in=1 2 3", + args: args{ + fieldName: "FieldInIntMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInIntMap, []int{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInIntMap elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_int8map_in=1 2 3", + args: args{ + fieldName: "FieldInInt8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInInt8Map, []int8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt8Map elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_int16map_in=1 2 3", + args: args{ + fieldName: "FieldInInt16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInInt16Map, []int16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt16Map elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_int32map_in=1 2 3", + args: args{ + fieldName: "FieldInInt32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInInt32Map, []int32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt32Map elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_int64map_in=1 2 3", + args: args{ + fieldName: "FieldInInt64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInInt64Map, []int64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt64Map elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uintmap_in=1 2 3", + args: args{ + fieldName: "FieldInUintMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInUintMap, []uint{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUintMap elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uint8map_in=1 2 3", + args: args{ + fieldName: "FieldInUint8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInUint8Map, []uint8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint8Map elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uint16map_in=1 2 3", + args: args{ + fieldName: "FieldInUint16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInUint16Map, []uint16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint16Map elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uint32map_in=1 2 3", + args: args{ + fieldName: "FieldInUint32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInUint32Map, []uint32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint32Map elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uint64map_in=1 2 3", + args: args{ + fieldName: "FieldInUint64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(types.MapOnlyContains(obj.FieldInUint64Map, []uint64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint64Map elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_float32map_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(types.MapOnlyContains(obj.FieldInFloat32Map, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32Map elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_float64map_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(types.MapOnlyContains(obj.FieldInFloat64Map, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64Map elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_boolmap_in=false", + args: args{ + fieldName: "FieldInBoolMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + fieldValidation: "in=false", + }, + want: `if !(types.MapOnlyContains(obj.FieldInBoolMap, []bool{false})) { +errs = append(errs, types.NewValidationError("FieldInBoolMap elements must be one of 'false'")) +} +`, + }, + { + name: "nin_string_nin=ab cd ef", + args: args{ + fieldName: "FieldNinString", + fieldType: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + fieldValidation: "nin=ab cd ef", + }, + want: `if !(obj.FieldNinString != "ab" && obj.FieldNinString != "cd" && obj.FieldNinString != "ef") { +errs = append(errs, types.NewValidationError("FieldNinString must not be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "nin_int_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt", + fieldType: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt != 12 && obj.FieldNinInt != 34 && obj.FieldNinInt != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int8_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt8", + fieldType: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt8 != 12 && obj.FieldNinInt8 != 34 && obj.FieldNinInt8 != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt8 must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int16_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt16", + fieldType: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt16 != 12 && obj.FieldNinInt16 != 34 && obj.FieldNinInt16 != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt16 must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int32_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt32", + fieldType: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt32 != 12 && obj.FieldNinInt32 != 34 && obj.FieldNinInt32 != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt32 must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int64_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt64", + fieldType: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt64 != 12 && obj.FieldNinInt64 != 34 && obj.FieldNinInt64 != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt64 must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint != 12 && obj.FieldNinUint != 34 && obj.FieldNinUint != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint8_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint8", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint8 != 12 && obj.FieldNinUint8 != 34 && obj.FieldNinUint8 != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint8 must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint16_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint16", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint16 != 12 && obj.FieldNinUint16 != 34 && obj.FieldNinUint16 != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint16 must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint32_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint32", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint32 != 12 && obj.FieldNinUint32 != 34 && obj.FieldNinUint32 != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint32 must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint64_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint64", + fieldType: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint64 != 12 && obj.FieldNinUint64 != 34 && obj.FieldNinUint64 != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint64 must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_float32_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat32", + fieldType: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(obj.FieldNinFloat32 != 11.11 && obj.FieldNinFloat32 != 22.22 && obj.FieldNinFloat32 != 33.33) { +errs = append(errs, types.NewValidationError("FieldNinFloat32 must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_float64_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat64", + fieldType: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(obj.FieldNinFloat64 != 11.11 && obj.FieldNinFloat64 != 22.22 && obj.FieldNinFloat64 != 33.33) { +errs = append(errs, types.NewValidationError("FieldNinFloat64 must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_bool_nin=true", + args: args{ + fieldName: "FieldNinBool", + fieldType: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + fieldValidation: "nin=true", + }, + want: `if !(obj.FieldNinBool != true) { +errs = append(errs, types.NewValidationError("FieldNinBool must not be one of 'true'")) +} +`, + }, + { + name: "nin_stringslice_nin=ab cd ef", + args: args{ + fieldName: "FieldNinStringSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + fieldValidation: "nin=ab cd ef", + }, + want: `if !(types.SliceNotContains(obj.FieldNinStringSlice, []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldNinStringSlice elements must not be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "nin_intslice_nin=12 34 56", + args: args{ + fieldName: "FieldNinIntSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinIntSlice, []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinIntSlice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int8slice_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinInt8Slice, []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt8Slice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int16slice_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinInt16Slice, []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt16Slice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int32slice_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinInt32Slice, []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt32Slice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int64slice_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinInt64Slice, []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt64Slice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uintslice_nin=12 34 56", + args: args{ + fieldName: "FieldNinUintSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUintSlice, []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUintSlice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint8slice_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint8Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUint8Slice, []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint8Slice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint16slice_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint16Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUint16Slice, []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint16Slice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint32slice_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUint32Slice, []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint32Slice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint64slice_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUint64Slice, []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint64Slice elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_float32slice_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat32Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(types.SliceNotContains(obj.FieldNinFloat32Slice, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32Slice elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_float64slice_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat64Slice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(types.SliceNotContains(obj.FieldNinFloat64Slice, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64Slice elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_boolslice_nin=true", + args: args{ + fieldName: "FieldNinBoolSlice", + fieldType: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + fieldValidation: "nin=true", + }, + want: `if !(types.SliceNotContains(obj.FieldNinBoolSlice, []bool{true})) { +errs = append(errs, types.NewValidationError("FieldNinBoolSlice elements must not be one of 'true'")) +} +`, + }, + { + name: "nin_stringarray_nin=ab cd ef", + args: args{ + fieldName: "FieldNinStringArray", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "string", Size: "3"}, + fieldValidation: "nin=ab cd ef", + }, + want: `if !(types.SliceNotContains(obj.FieldNinStringArray[:], []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldNinStringArray elements must not be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "nin_intarray_nin=12 34 56", + args: args{ + fieldName: "FieldNinIntArray", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinIntArray[:], []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinIntArray elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int8array_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt8Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int8", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinInt8Array[:], []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt8Array elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int16array_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt16Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int16", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinInt16Array[:], []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt16Array elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int32array_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt32Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int32", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinInt32Array[:], []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt32Array elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int64array_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt64Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "int64", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinInt64Array[:], []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt64Array elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uintarray_nin=12 34 56", + args: args{ + fieldName: "FieldNinUintArray", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUintArray[:], []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUintArray elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint8array_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint8Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint8", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUint8Array[:], []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint8Array elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint16array_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint16Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint16", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUint16Array[:], []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint16Array elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint32array_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint32Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint32", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUint32Array[:], []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint32Array elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint64array_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint64Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "uint64", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(types.SliceNotContains(obj.FieldNinUint64Array[:], []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint64Array elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_float32array_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat32Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "float32", Size: "3"}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(types.SliceNotContains(obj.FieldNinFloat32Array[:], []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32Array elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_float64array_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat64Array", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "float64", Size: "3"}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(types.SliceNotContains(obj.FieldNinFloat64Array[:], []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64Array elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_boolarray_nin=true", + args: args{ + fieldName: "FieldNinBoolArray", + fieldType: common.FieldType{ComposedType: "[N]", BaseType: "bool", Size: "3"}, + fieldValidation: "nin=true", + }, + want: `if !(types.SliceNotContains(obj.FieldNinBoolArray[:], []bool{true})) { +errs = append(errs, types.NewValidationError("FieldNinBoolArray elements must not be one of 'true'")) +} +`, + }, + { + name: "nin_stringmap_nin=a b c", + args: args{ + fieldName: "FieldNinStringMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + fieldValidation: "nin=a b c", + }, + want: `if !(types.MapNotContains(obj.FieldNinStringMap, []string{"a", "b", "c"})) { +errs = append(errs, types.NewValidationError("FieldNinStringMap elements must not be one of 'a' 'b' 'c'")) +} +`, + }, + { + name: "nin_intmap_nin=1 2 3", + args: args{ + fieldName: "FieldNinIntMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinIntMap, []int{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinIntMap elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_int8map_nin=1 2 3", + args: args{ + fieldName: "FieldNinInt8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinInt8Map, []int8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt8Map elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_int16map_nin=1 2 3", + args: args{ + fieldName: "FieldNinInt16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinInt16Map, []int16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt16Map elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_int32map_nin=1 2 3", + args: args{ + fieldName: "FieldNinInt32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinInt32Map, []int32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt32Map elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_int64map_nin=1 2 3", + args: args{ + fieldName: "FieldNinInt64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinInt64Map, []int64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt64Map elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uintmap_nin=1 2 3", + args: args{ + fieldName: "FieldNinUintMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinUintMap, []uint{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUintMap elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uint8map_nin=1 2 3", + args: args{ + fieldName: "FieldNinUint8Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinUint8Map, []uint8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint8Map elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uint16map_nin=1 2 3", + args: args{ + fieldName: "FieldNinUint16Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinUint16Map, []uint16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint16Map elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uint32map_nin=1 2 3", + args: args{ + fieldName: "FieldNinUint32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinUint32Map, []uint32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint32Map elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uint64map_nin=1 2 3", + args: args{ + fieldName: "FieldNinUint64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(types.MapNotContains(obj.FieldNinUint64Map, []uint64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint64Map elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_float32map_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat32Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(types.MapNotContains(obj.FieldNinFloat32Map, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32Map elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_float64map_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat64Map", + fieldType: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(types.MapNotContains(obj.FieldNinFloat64Map, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64Map elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_boolmap_nin=false", + args: args{ + fieldName: "FieldNinBoolMap", + fieldType: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + fieldValidation: "nin=false", + }, + want: `if !(types.MapNotContains(obj.FieldNinBoolMap, []bool{false})) { +errs = append(errs, types.NewValidationError("FieldNinBoolMap elements must not be one of 'false'")) +} +`, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gv := GenValidations{} + validation := AssertParserValidation(t, tt.args.fieldValidation) + got, err := gv.BuildValidationCode(tt.args.fieldName, tt.args.fieldType, []*analyzer.Validation{validation}) + if err != nil { + t.Errorf("BuildValidationCode() error = %v, wantErr %v", err, nil) + return + } + if got != tt.want { + t.Errorf("BuildValidationCode() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/internal/codegenerator/generated_validation_code_pointer_test.go b/internal/codegenerator/generated_validation_code_pointer_test.go new file mode 100644 index 0000000..2ac92e6 --- /dev/null +++ b/internal/codegenerator/generated_validation_code_pointer_test.go @@ -0,0 +1,4045 @@ +package codegenerator + +import ( + "testing" + + "github.com/opencodeco/validgen/internal/analyzer" + "github.com/opencodeco/validgen/internal/common" +) + +func TestBuildValidationCodePointer(t *testing.T) { + type args struct { + fieldName string + fieldType common.FieldType + fieldValidation string + } + tests := []struct { + name string + args args + want string + }{ + { + name: "email_stringpointer_email", + args: args{ + fieldName: "FieldEmailStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "email", + }, + want: `if !(obj.FieldEmailStringPointer != nil && types.IsValidEmail(*obj.FieldEmailStringPointer)) { +errs = append(errs, types.NewValidationError("FieldEmailStringPointer must be a valid email")) +} +`, + }, + { + name: "required_stringpointer_required", + args: args{ + fieldName: "FieldRequiredStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredStringPointer != nil && *obj.FieldRequiredStringPointer != "") { +errs = append(errs, types.NewValidationError("FieldRequiredStringPointer is required")) +} +`, + }, + { + name: "required_intpointer_required", + args: args{ + fieldName: "FieldRequiredIntPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredIntPointer != nil && *obj.FieldRequiredIntPointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntPointer is required")) +} +`, + }, + { + name: "required_int8pointer_required", + args: args{ + fieldName: "FieldRequiredInt8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt8Pointer != nil && *obj.FieldRequiredInt8Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8Pointer is required")) +} +`, + }, + { + name: "required_int16pointer_required", + args: args{ + fieldName: "FieldRequiredInt16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt16Pointer != nil && *obj.FieldRequiredInt16Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16Pointer is required")) +} +`, + }, + { + name: "required_int32pointer_required", + args: args{ + fieldName: "FieldRequiredInt32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt32Pointer != nil && *obj.FieldRequiredInt32Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32Pointer is required")) +} +`, + }, + { + name: "required_int64pointer_required", + args: args{ + fieldName: "FieldRequiredInt64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt64Pointer != nil && *obj.FieldRequiredInt64Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64Pointer is required")) +} +`, + }, + { + name: "required_uintpointer_required", + args: args{ + fieldName: "FieldRequiredUintPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUintPointer != nil && *obj.FieldRequiredUintPointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintPointer is required")) +} +`, + }, + { + name: "required_uint8pointer_required", + args: args{ + fieldName: "FieldRequiredUint8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint8Pointer != nil && *obj.FieldRequiredUint8Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8Pointer is required")) +} +`, + }, + { + name: "required_uint16pointer_required", + args: args{ + fieldName: "FieldRequiredUint16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint16Pointer != nil && *obj.FieldRequiredUint16Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16Pointer is required")) +} +`, + }, + { + name: "required_uint32pointer_required", + args: args{ + fieldName: "FieldRequiredUint32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint32Pointer != nil && *obj.FieldRequiredUint32Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32Pointer is required")) +} +`, + }, + { + name: "required_uint64pointer_required", + args: args{ + fieldName: "FieldRequiredUint64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint64Pointer != nil && *obj.FieldRequiredUint64Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64Pointer is required")) +} +`, + }, + { + name: "required_float32pointer_required", + args: args{ + fieldName: "FieldRequiredFloat32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat32Pointer != nil && *obj.FieldRequiredFloat32Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32Pointer is required")) +} +`, + }, + { + name: "required_float64pointer_required", + args: args{ + fieldName: "FieldRequiredFloat64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat64Pointer != nil && *obj.FieldRequiredFloat64Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64Pointer is required")) +} +`, + }, + { + name: "required_boolpointer_required", + args: args{ + fieldName: "FieldRequiredBoolPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredBoolPointer != nil && *obj.FieldRequiredBoolPointer != false) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolPointer is required")) +} +`, + }, + { + name: "required_stringslicepointer_required", + args: args{ + fieldName: "FieldRequiredStringSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredStringSlicePointer != nil && len(*obj.FieldRequiredStringSlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredStringSlicePointer must not be empty")) +} +`, + }, + { + name: "required_intslicepointer_required", + args: args{ + fieldName: "FieldRequiredIntSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredIntSlicePointer != nil && len(*obj.FieldRequiredIntSlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntSlicePointer must not be empty")) +} +`, + }, + { + name: "required_int8slicepointer_required", + args: args{ + fieldName: "FieldRequiredInt8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt8SlicePointer != nil && len(*obj.FieldRequiredInt8SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8SlicePointer must not be empty")) +} +`, + }, + { + name: "required_int16slicepointer_required", + args: args{ + fieldName: "FieldRequiredInt16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt16SlicePointer != nil && len(*obj.FieldRequiredInt16SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16SlicePointer must not be empty")) +} +`, + }, + { + name: "required_int32slicepointer_required", + args: args{ + fieldName: "FieldRequiredInt32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt32SlicePointer != nil && len(*obj.FieldRequiredInt32SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32SlicePointer must not be empty")) +} +`, + }, + { + name: "required_int64slicepointer_required", + args: args{ + fieldName: "FieldRequiredInt64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt64SlicePointer != nil && len(*obj.FieldRequiredInt64SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64SlicePointer must not be empty")) +} +`, + }, + { + name: "required_uintslicepointer_required", + args: args{ + fieldName: "FieldRequiredUintSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUintSlicePointer != nil && len(*obj.FieldRequiredUintSlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintSlicePointer must not be empty")) +} +`, + }, + { + name: "required_uint8slicepointer_required", + args: args{ + fieldName: "FieldRequiredUint8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint8SlicePointer != nil && len(*obj.FieldRequiredUint8SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8SlicePointer must not be empty")) +} +`, + }, + { + name: "required_uint16slicepointer_required", + args: args{ + fieldName: "FieldRequiredUint16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint16SlicePointer != nil && len(*obj.FieldRequiredUint16SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16SlicePointer must not be empty")) +} +`, + }, + { + name: "required_uint32slicepointer_required", + args: args{ + fieldName: "FieldRequiredUint32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint32SlicePointer != nil && len(*obj.FieldRequiredUint32SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32SlicePointer must not be empty")) +} +`, + }, + { + name: "required_uint64slicepointer_required", + args: args{ + fieldName: "FieldRequiredUint64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint64SlicePointer != nil && len(*obj.FieldRequiredUint64SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64SlicePointer must not be empty")) +} +`, + }, + { + name: "required_float32slicepointer_required", + args: args{ + fieldName: "FieldRequiredFloat32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat32SlicePointer != nil && len(*obj.FieldRequiredFloat32SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32SlicePointer must not be empty")) +} +`, + }, + { + name: "required_float64slicepointer_required", + args: args{ + fieldName: "FieldRequiredFloat64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat64SlicePointer != nil && len(*obj.FieldRequiredFloat64SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64SlicePointer must not be empty")) +} +`, + }, + { + name: "required_boolslicepointer_required", + args: args{ + fieldName: "FieldRequiredBoolSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredBoolSlicePointer != nil && len(*obj.FieldRequiredBoolSlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolSlicePointer must not be empty")) +} +`, + }, + { + name: "required_stringarraypointer_required", + args: args{ + fieldName: "FieldRequiredStringArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "string", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredStringArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredStringArrayPointer must not be empty")) +} +`, + }, + { + name: "required_intarraypointer_required", + args: args{ + fieldName: "FieldRequiredIntArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredIntArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredIntArrayPointer must not be empty")) +} +`, + }, + { + name: "required_int8arraypointer_required", + args: args{ + fieldName: "FieldRequiredInt8ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int8", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt8ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_int16arraypointer_required", + args: args{ + fieldName: "FieldRequiredInt16ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int16", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt16ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_int32arraypointer_required", + args: args{ + fieldName: "FieldRequiredInt32ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int32", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt32ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_int64arraypointer_required", + args: args{ + fieldName: "FieldRequiredInt64ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int64", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt64ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_uintarraypointer_required", + args: args{ + fieldName: "FieldRequiredUintArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUintArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUintArrayPointer must not be empty")) +} +`, + }, + { + name: "required_uint8arraypointer_required", + args: args{ + fieldName: "FieldRequiredUint8ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint8", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint8ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_uint16arraypointer_required", + args: args{ + fieldName: "FieldRequiredUint16ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint16", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint16ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_uint32arraypointer_required", + args: args{ + fieldName: "FieldRequiredUint32ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint32", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint32ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_uint64arraypointer_required", + args: args{ + fieldName: "FieldRequiredUint64ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint64", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint64ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_float32arraypointer_required", + args: args{ + fieldName: "FieldRequiredFloat32ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "float32", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat32ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_float64arraypointer_required", + args: args{ + fieldName: "FieldRequiredFloat64ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "float64", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat64ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64ArrayPointer must not be empty")) +} +`, + }, + { + name: "required_boolarraypointer_required", + args: args{ + fieldName: "FieldRequiredBoolArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "bool", Size: "3"}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredBoolArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolArrayPointer must not be empty")) +} +`, + }, + { + name: "required_stringmappointer_required", + args: args{ + fieldName: "FieldRequiredStringMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredStringMapPointer != nil && len(*obj.FieldRequiredStringMapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredStringMapPointer must not be empty")) +} +`, + }, + { + name: "required_intmappointer_required", + args: args{ + fieldName: "FieldRequiredIntMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredIntMapPointer != nil && len(*obj.FieldRequiredIntMapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntMapPointer must not be empty")) +} +`, + }, + { + name: "required_int8mappointer_required", + args: args{ + fieldName: "FieldRequiredInt8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt8MapPointer != nil && len(*obj.FieldRequiredInt8MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8MapPointer must not be empty")) +} +`, + }, + { + name: "required_int16mappointer_required", + args: args{ + fieldName: "FieldRequiredInt16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt16MapPointer != nil && len(*obj.FieldRequiredInt16MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16MapPointer must not be empty")) +} +`, + }, + { + name: "required_int32mappointer_required", + args: args{ + fieldName: "FieldRequiredInt32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt32MapPointer != nil && len(*obj.FieldRequiredInt32MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32MapPointer must not be empty")) +} +`, + }, + { + name: "required_int64mappointer_required", + args: args{ + fieldName: "FieldRequiredInt64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredInt64MapPointer != nil && len(*obj.FieldRequiredInt64MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64MapPointer must not be empty")) +} +`, + }, + { + name: "required_uintmappointer_required", + args: args{ + fieldName: "FieldRequiredUintMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUintMapPointer != nil && len(*obj.FieldRequiredUintMapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintMapPointer must not be empty")) +} +`, + }, + { + name: "required_uint8mappointer_required", + args: args{ + fieldName: "FieldRequiredUint8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint8MapPointer != nil && len(*obj.FieldRequiredUint8MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8MapPointer must not be empty")) +} +`, + }, + { + name: "required_uint16mappointer_required", + args: args{ + fieldName: "FieldRequiredUint16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint16MapPointer != nil && len(*obj.FieldRequiredUint16MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16MapPointer must not be empty")) +} +`, + }, + { + name: "required_uint32mappointer_required", + args: args{ + fieldName: "FieldRequiredUint32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint32MapPointer != nil && len(*obj.FieldRequiredUint32MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32MapPointer must not be empty")) +} +`, + }, + { + name: "required_uint64mappointer_required", + args: args{ + fieldName: "FieldRequiredUint64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredUint64MapPointer != nil && len(*obj.FieldRequiredUint64MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64MapPointer must not be empty")) +} +`, + }, + { + name: "required_float32mappointer_required", + args: args{ + fieldName: "FieldRequiredFloat32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat32MapPointer != nil && len(*obj.FieldRequiredFloat32MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32MapPointer must not be empty")) +} +`, + }, + { + name: "required_float64mappointer_required", + args: args{ + fieldName: "FieldRequiredFloat64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredFloat64MapPointer != nil && len(*obj.FieldRequiredFloat64MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64MapPointer must not be empty")) +} +`, + }, + { + name: "required_boolmappointer_required", + args: args{ + fieldName: "FieldRequiredBoolMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + fieldValidation: "required", + }, + want: `if !(obj.FieldRequiredBoolMapPointer != nil && len(*obj.FieldRequiredBoolMapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolMapPointer must not be empty")) +} +`, + }, + { + name: "eq_stringpointer_eq=abcde", + args: args{ + fieldName: "FieldEqStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "eq=abcde", + }, + want: `if !(obj.FieldEqStringPointer != nil && *obj.FieldEqStringPointer == "abcde") { +errs = append(errs, types.NewValidationError("FieldEqStringPointer must be equal to 'abcde'")) +} +`, + }, + { + name: "eq_intpointer_eq=32", + args: args{ + fieldName: "FieldEqIntPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqIntPointer != nil && *obj.FieldEqIntPointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqIntPointer must be equal to 32")) +} +`, + }, + { + name: "eq_int8pointer_eq=32", + args: args{ + fieldName: "FieldEqInt8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqInt8Pointer != nil && *obj.FieldEqInt8Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt8Pointer must be equal to 32")) +} +`, + }, + { + name: "eq_int16pointer_eq=32", + args: args{ + fieldName: "FieldEqInt16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqInt16Pointer != nil && *obj.FieldEqInt16Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt16Pointer must be equal to 32")) +} +`, + }, + { + name: "eq_int32pointer_eq=32", + args: args{ + fieldName: "FieldEqInt32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqInt32Pointer != nil && *obj.FieldEqInt32Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt32Pointer must be equal to 32")) +} +`, + }, + { + name: "eq_int64pointer_eq=32", + args: args{ + fieldName: "FieldEqInt64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqInt64Pointer != nil && *obj.FieldEqInt64Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt64Pointer must be equal to 32")) +} +`, + }, + { + name: "eq_uintpointer_eq=32", + args: args{ + fieldName: "FieldEqUintPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUintPointer != nil && *obj.FieldEqUintPointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUintPointer must be equal to 32")) +} +`, + }, + { + name: "eq_uint8pointer_eq=32", + args: args{ + fieldName: "FieldEqUint8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUint8Pointer != nil && *obj.FieldEqUint8Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint8Pointer must be equal to 32")) +} +`, + }, + { + name: "eq_uint16pointer_eq=32", + args: args{ + fieldName: "FieldEqUint16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUint16Pointer != nil && *obj.FieldEqUint16Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint16Pointer must be equal to 32")) +} +`, + }, + { + name: "eq_uint32pointer_eq=32", + args: args{ + fieldName: "FieldEqUint32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUint32Pointer != nil && *obj.FieldEqUint32Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint32Pointer must be equal to 32")) +} +`, + }, + { + name: "eq_uint64pointer_eq=32", + args: args{ + fieldName: "FieldEqUint64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + fieldValidation: "eq=32", + }, + want: `if !(obj.FieldEqUint64Pointer != nil && *obj.FieldEqUint64Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint64Pointer must be equal to 32")) +} +`, + }, + { + name: "eq_float32pointer_eq=12.34", + args: args{ + fieldName: "FieldEqFloat32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + fieldValidation: "eq=12.34", + }, + want: `if !(obj.FieldEqFloat32Pointer != nil && *obj.FieldEqFloat32Pointer == 12.34) { +errs = append(errs, types.NewValidationError("FieldEqFloat32Pointer must be equal to 12.34")) +} +`, + }, + { + name: "eq_float64pointer_eq=12.34", + args: args{ + fieldName: "FieldEqFloat64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + fieldValidation: "eq=12.34", + }, + want: `if !(obj.FieldEqFloat64Pointer != nil && *obj.FieldEqFloat64Pointer == 12.34) { +errs = append(errs, types.NewValidationError("FieldEqFloat64Pointer must be equal to 12.34")) +} +`, + }, + { + name: "eq_boolpointer_eq=true", + args: args{ + fieldName: "FieldEqBoolPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + fieldValidation: "eq=true", + }, + want: `if !(obj.FieldEqBoolPointer != nil && *obj.FieldEqBoolPointer == true) { +errs = append(errs, types.NewValidationError("FieldEqBoolPointer must be equal to true")) +} +`, + }, + { + name: "neq_stringpointer_neq=abcde", + args: args{ + fieldName: "FieldNeqStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "neq=abcde", + }, + want: `if !(obj.FieldNeqStringPointer != nil && *obj.FieldNeqStringPointer != "abcde") { +errs = append(errs, types.NewValidationError("FieldNeqStringPointer must not be equal to 'abcde'")) +} +`, + }, + { + name: "neq_intpointer_neq=32", + args: args{ + fieldName: "FieldNeqIntPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqIntPointer != nil && *obj.FieldNeqIntPointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqIntPointer must not be equal to 32")) +} +`, + }, + { + name: "neq_int8pointer_neq=32", + args: args{ + fieldName: "FieldNeqInt8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqInt8Pointer != nil && *obj.FieldNeqInt8Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt8Pointer must not be equal to 32")) +} +`, + }, + { + name: "neq_int16pointer_neq=32", + args: args{ + fieldName: "FieldNeqInt16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqInt16Pointer != nil && *obj.FieldNeqInt16Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt16Pointer must not be equal to 32")) +} +`, + }, + { + name: "neq_int32pointer_neq=32", + args: args{ + fieldName: "FieldNeqInt32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqInt32Pointer != nil && *obj.FieldNeqInt32Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt32Pointer must not be equal to 32")) +} +`, + }, + { + name: "neq_int64pointer_neq=32", + args: args{ + fieldName: "FieldNeqInt64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqInt64Pointer != nil && *obj.FieldNeqInt64Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt64Pointer must not be equal to 32")) +} +`, + }, + { + name: "neq_uintpointer_neq=32", + args: args{ + fieldName: "FieldNeqUintPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUintPointer != nil && *obj.FieldNeqUintPointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUintPointer must not be equal to 32")) +} +`, + }, + { + name: "neq_uint8pointer_neq=32", + args: args{ + fieldName: "FieldNeqUint8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUint8Pointer != nil && *obj.FieldNeqUint8Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint8Pointer must not be equal to 32")) +} +`, + }, + { + name: "neq_uint16pointer_neq=32", + args: args{ + fieldName: "FieldNeqUint16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUint16Pointer != nil && *obj.FieldNeqUint16Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint16Pointer must not be equal to 32")) +} +`, + }, + { + name: "neq_uint32pointer_neq=32", + args: args{ + fieldName: "FieldNeqUint32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUint32Pointer != nil && *obj.FieldNeqUint32Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint32Pointer must not be equal to 32")) +} +`, + }, + { + name: "neq_uint64pointer_neq=32", + args: args{ + fieldName: "FieldNeqUint64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + fieldValidation: "neq=32", + }, + want: `if !(obj.FieldNeqUint64Pointer != nil && *obj.FieldNeqUint64Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint64Pointer must not be equal to 32")) +} +`, + }, + { + name: "neq_float32pointer_neq=12.34", + args: args{ + fieldName: "FieldNeqFloat32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + fieldValidation: "neq=12.34", + }, + want: `if !(obj.FieldNeqFloat32Pointer != nil && *obj.FieldNeqFloat32Pointer != 12.34) { +errs = append(errs, types.NewValidationError("FieldNeqFloat32Pointer must not be equal to 12.34")) +} +`, + }, + { + name: "neq_float64pointer_neq=12.34", + args: args{ + fieldName: "FieldNeqFloat64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + fieldValidation: "neq=12.34", + }, + want: `if !(obj.FieldNeqFloat64Pointer != nil && *obj.FieldNeqFloat64Pointer != 12.34) { +errs = append(errs, types.NewValidationError("FieldNeqFloat64Pointer must not be equal to 12.34")) +} +`, + }, + { + name: "neq_boolpointer_neq=true", + args: args{ + fieldName: "FieldNeqBoolPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + fieldValidation: "neq=true", + }, + want: `if !(obj.FieldNeqBoolPointer != nil && *obj.FieldNeqBoolPointer != true) { +errs = append(errs, types.NewValidationError("FieldNeqBoolPointer must not be equal to true")) +} +`, + }, + { + name: "gt_intpointer_gt=32", + args: args{ + fieldName: "FieldGtIntPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtIntPointer != nil && *obj.FieldGtIntPointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtIntPointer must be > 32")) +} +`, + }, + { + name: "gt_int8pointer_gt=32", + args: args{ + fieldName: "FieldGtInt8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtInt8Pointer != nil && *obj.FieldGtInt8Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt8Pointer must be > 32")) +} +`, + }, + { + name: "gt_int16pointer_gt=32", + args: args{ + fieldName: "FieldGtInt16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtInt16Pointer != nil && *obj.FieldGtInt16Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt16Pointer must be > 32")) +} +`, + }, + { + name: "gt_int32pointer_gt=32", + args: args{ + fieldName: "FieldGtInt32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtInt32Pointer != nil && *obj.FieldGtInt32Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt32Pointer must be > 32")) +} +`, + }, + { + name: "gt_int64pointer_gt=32", + args: args{ + fieldName: "FieldGtInt64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtInt64Pointer != nil && *obj.FieldGtInt64Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt64Pointer must be > 32")) +} +`, + }, + { + name: "gt_uintpointer_gt=32", + args: args{ + fieldName: "FieldGtUintPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUintPointer != nil && *obj.FieldGtUintPointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUintPointer must be > 32")) +} +`, + }, + { + name: "gt_uint8pointer_gt=32", + args: args{ + fieldName: "FieldGtUint8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUint8Pointer != nil && *obj.FieldGtUint8Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint8Pointer must be > 32")) +} +`, + }, + { + name: "gt_uint16pointer_gt=32", + args: args{ + fieldName: "FieldGtUint16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUint16Pointer != nil && *obj.FieldGtUint16Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint16Pointer must be > 32")) +} +`, + }, + { + name: "gt_uint32pointer_gt=32", + args: args{ + fieldName: "FieldGtUint32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUint32Pointer != nil && *obj.FieldGtUint32Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint32Pointer must be > 32")) +} +`, + }, + { + name: "gt_uint64pointer_gt=32", + args: args{ + fieldName: "FieldGtUint64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + fieldValidation: "gt=32", + }, + want: `if !(obj.FieldGtUint64Pointer != nil && *obj.FieldGtUint64Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint64Pointer must be > 32")) +} +`, + }, + { + name: "gt_float32pointer_gt=12.34", + args: args{ + fieldName: "FieldGtFloat32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + fieldValidation: "gt=12.34", + }, + want: `if !(obj.FieldGtFloat32Pointer != nil && *obj.FieldGtFloat32Pointer > 12.34) { +errs = append(errs, types.NewValidationError("FieldGtFloat32Pointer must be > 12.34")) +} +`, + }, + { + name: "gt_float64pointer_gt=12.34", + args: args{ + fieldName: "FieldGtFloat64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + fieldValidation: "gt=12.34", + }, + want: `if !(obj.FieldGtFloat64Pointer != nil && *obj.FieldGtFloat64Pointer > 12.34) { +errs = append(errs, types.NewValidationError("FieldGtFloat64Pointer must be > 12.34")) +} +`, + }, + { + name: "gte_intpointer_gte=32", + args: args{ + fieldName: "FieldGteIntPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteIntPointer != nil && *obj.FieldGteIntPointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteIntPointer must be >= 32")) +} +`, + }, + { + name: "gte_int8pointer_gte=32", + args: args{ + fieldName: "FieldGteInt8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteInt8Pointer != nil && *obj.FieldGteInt8Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt8Pointer must be >= 32")) +} +`, + }, + { + name: "gte_int16pointer_gte=32", + args: args{ + fieldName: "FieldGteInt16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteInt16Pointer != nil && *obj.FieldGteInt16Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt16Pointer must be >= 32")) +} +`, + }, + { + name: "gte_int32pointer_gte=32", + args: args{ + fieldName: "FieldGteInt32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteInt32Pointer != nil && *obj.FieldGteInt32Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt32Pointer must be >= 32")) +} +`, + }, + { + name: "gte_int64pointer_gte=32", + args: args{ + fieldName: "FieldGteInt64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteInt64Pointer != nil && *obj.FieldGteInt64Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt64Pointer must be >= 32")) +} +`, + }, + { + name: "gte_uintpointer_gte=32", + args: args{ + fieldName: "FieldGteUintPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUintPointer != nil && *obj.FieldGteUintPointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUintPointer must be >= 32")) +} +`, + }, + { + name: "gte_uint8pointer_gte=32", + args: args{ + fieldName: "FieldGteUint8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUint8Pointer != nil && *obj.FieldGteUint8Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint8Pointer must be >= 32")) +} +`, + }, + { + name: "gte_uint16pointer_gte=32", + args: args{ + fieldName: "FieldGteUint16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUint16Pointer != nil && *obj.FieldGteUint16Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint16Pointer must be >= 32")) +} +`, + }, + { + name: "gte_uint32pointer_gte=32", + args: args{ + fieldName: "FieldGteUint32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUint32Pointer != nil && *obj.FieldGteUint32Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint32Pointer must be >= 32")) +} +`, + }, + { + name: "gte_uint64pointer_gte=32", + args: args{ + fieldName: "FieldGteUint64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + fieldValidation: "gte=32", + }, + want: `if !(obj.FieldGteUint64Pointer != nil && *obj.FieldGteUint64Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint64Pointer must be >= 32")) +} +`, + }, + { + name: "gte_float32pointer_gte=12.34", + args: args{ + fieldName: "FieldGteFloat32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + fieldValidation: "gte=12.34", + }, + want: `if !(obj.FieldGteFloat32Pointer != nil && *obj.FieldGteFloat32Pointer >= 12.34) { +errs = append(errs, types.NewValidationError("FieldGteFloat32Pointer must be >= 12.34")) +} +`, + }, + { + name: "gte_float64pointer_gte=12.34", + args: args{ + fieldName: "FieldGteFloat64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + fieldValidation: "gte=12.34", + }, + want: `if !(obj.FieldGteFloat64Pointer != nil && *obj.FieldGteFloat64Pointer >= 12.34) { +errs = append(errs, types.NewValidationError("FieldGteFloat64Pointer must be >= 12.34")) +} +`, + }, + { + name: "lt_intpointer_lt=32", + args: args{ + fieldName: "FieldLtIntPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtIntPointer != nil && *obj.FieldLtIntPointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtIntPointer must be < 32")) +} +`, + }, + { + name: "lt_int8pointer_lt=32", + args: args{ + fieldName: "FieldLtInt8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtInt8Pointer != nil && *obj.FieldLtInt8Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt8Pointer must be < 32")) +} +`, + }, + { + name: "lt_int16pointer_lt=32", + args: args{ + fieldName: "FieldLtInt16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtInt16Pointer != nil && *obj.FieldLtInt16Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt16Pointer must be < 32")) +} +`, + }, + { + name: "lt_int32pointer_lt=32", + args: args{ + fieldName: "FieldLtInt32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtInt32Pointer != nil && *obj.FieldLtInt32Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt32Pointer must be < 32")) +} +`, + }, + { + name: "lt_int64pointer_lt=32", + args: args{ + fieldName: "FieldLtInt64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtInt64Pointer != nil && *obj.FieldLtInt64Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt64Pointer must be < 32")) +} +`, + }, + { + name: "lt_uintpointer_lt=32", + args: args{ + fieldName: "FieldLtUintPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUintPointer != nil && *obj.FieldLtUintPointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUintPointer must be < 32")) +} +`, + }, + { + name: "lt_uint8pointer_lt=32", + args: args{ + fieldName: "FieldLtUint8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUint8Pointer != nil && *obj.FieldLtUint8Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint8Pointer must be < 32")) +} +`, + }, + { + name: "lt_uint16pointer_lt=32", + args: args{ + fieldName: "FieldLtUint16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUint16Pointer != nil && *obj.FieldLtUint16Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint16Pointer must be < 32")) +} +`, + }, + { + name: "lt_uint32pointer_lt=32", + args: args{ + fieldName: "FieldLtUint32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUint32Pointer != nil && *obj.FieldLtUint32Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint32Pointer must be < 32")) +} +`, + }, + { + name: "lt_uint64pointer_lt=32", + args: args{ + fieldName: "FieldLtUint64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + fieldValidation: "lt=32", + }, + want: `if !(obj.FieldLtUint64Pointer != nil && *obj.FieldLtUint64Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint64Pointer must be < 32")) +} +`, + }, + { + name: "lt_float32pointer_lt=12.34", + args: args{ + fieldName: "FieldLtFloat32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + fieldValidation: "lt=12.34", + }, + want: `if !(obj.FieldLtFloat32Pointer != nil && *obj.FieldLtFloat32Pointer < 12.34) { +errs = append(errs, types.NewValidationError("FieldLtFloat32Pointer must be < 12.34")) +} +`, + }, + { + name: "lt_float64pointer_lt=12.34", + args: args{ + fieldName: "FieldLtFloat64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + fieldValidation: "lt=12.34", + }, + want: `if !(obj.FieldLtFloat64Pointer != nil && *obj.FieldLtFloat64Pointer < 12.34) { +errs = append(errs, types.NewValidationError("FieldLtFloat64Pointer must be < 12.34")) +} +`, + }, + { + name: "lte_intpointer_lte=32", + args: args{ + fieldName: "FieldLteIntPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteIntPointer != nil && *obj.FieldLteIntPointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteIntPointer must be <= 32")) +} +`, + }, + { + name: "lte_int8pointer_lte=32", + args: args{ + fieldName: "FieldLteInt8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteInt8Pointer != nil && *obj.FieldLteInt8Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt8Pointer must be <= 32")) +} +`, + }, + { + name: "lte_int16pointer_lte=32", + args: args{ + fieldName: "FieldLteInt16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteInt16Pointer != nil && *obj.FieldLteInt16Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt16Pointer must be <= 32")) +} +`, + }, + { + name: "lte_int32pointer_lte=32", + args: args{ + fieldName: "FieldLteInt32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteInt32Pointer != nil && *obj.FieldLteInt32Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt32Pointer must be <= 32")) +} +`, + }, + { + name: "lte_int64pointer_lte=32", + args: args{ + fieldName: "FieldLteInt64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteInt64Pointer != nil && *obj.FieldLteInt64Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt64Pointer must be <= 32")) +} +`, + }, + { + name: "lte_uintpointer_lte=32", + args: args{ + fieldName: "FieldLteUintPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUintPointer != nil && *obj.FieldLteUintPointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUintPointer must be <= 32")) +} +`, + }, + { + name: "lte_uint8pointer_lte=32", + args: args{ + fieldName: "FieldLteUint8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUint8Pointer != nil && *obj.FieldLteUint8Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint8Pointer must be <= 32")) +} +`, + }, + { + name: "lte_uint16pointer_lte=32", + args: args{ + fieldName: "FieldLteUint16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUint16Pointer != nil && *obj.FieldLteUint16Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint16Pointer must be <= 32")) +} +`, + }, + { + name: "lte_uint32pointer_lte=32", + args: args{ + fieldName: "FieldLteUint32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUint32Pointer != nil && *obj.FieldLteUint32Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint32Pointer must be <= 32")) +} +`, + }, + { + name: "lte_uint64pointer_lte=32", + args: args{ + fieldName: "FieldLteUint64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + fieldValidation: "lte=32", + }, + want: `if !(obj.FieldLteUint64Pointer != nil && *obj.FieldLteUint64Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint64Pointer must be <= 32")) +} +`, + }, + { + name: "lte_float32pointer_lte=12.34", + args: args{ + fieldName: "FieldLteFloat32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + fieldValidation: "lte=12.34", + }, + want: `if !(obj.FieldLteFloat32Pointer != nil && *obj.FieldLteFloat32Pointer <= 12.34) { +errs = append(errs, types.NewValidationError("FieldLteFloat32Pointer must be <= 12.34")) +} +`, + }, + { + name: "lte_float64pointer_lte=12.34", + args: args{ + fieldName: "FieldLteFloat64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + fieldValidation: "lte=12.34", + }, + want: `if !(obj.FieldLteFloat64Pointer != nil && *obj.FieldLteFloat64Pointer <= 12.34) { +errs = append(errs, types.NewValidationError("FieldLteFloat64Pointer must be <= 12.34")) +} +`, + }, + { + name: "min_stringpointer_min=5", + args: args{ + fieldName: "FieldMinStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "min=5", + }, + want: `if !(obj.FieldMinStringPointer != nil && len(*obj.FieldMinStringPointer) >= 5) { +errs = append(errs, types.NewValidationError("FieldMinStringPointer length must be >= 5")) +} +`, + }, + { + name: "min_stringslicepointer_min=2", + args: args{ + fieldName: "FieldMinStringSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinStringSlicePointer != nil && len(*obj.FieldMinStringSlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinStringSlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_intslicepointer_min=2", + args: args{ + fieldName: "FieldMinIntSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinIntSlicePointer != nil && len(*obj.FieldMinIntSlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinIntSlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_int8slicepointer_min=2", + args: args{ + fieldName: "FieldMinInt8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinInt8SlicePointer != nil && len(*obj.FieldMinInt8SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt8SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_int16slicepointer_min=2", + args: args{ + fieldName: "FieldMinInt16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinInt16SlicePointer != nil && len(*obj.FieldMinInt16SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt16SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_int32slicepointer_min=2", + args: args{ + fieldName: "FieldMinInt32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinInt32SlicePointer != nil && len(*obj.FieldMinInt32SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt32SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_int64slicepointer_min=2", + args: args{ + fieldName: "FieldMinInt64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinInt64SlicePointer != nil && len(*obj.FieldMinInt64SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt64SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uintslicepointer_min=2", + args: args{ + fieldName: "FieldMinUintSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUintSlicePointer != nil && len(*obj.FieldMinUintSlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUintSlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uint8slicepointer_min=2", + args: args{ + fieldName: "FieldMinUint8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUint8SlicePointer != nil && len(*obj.FieldMinUint8SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint8SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uint16slicepointer_min=2", + args: args{ + fieldName: "FieldMinUint16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUint16SlicePointer != nil && len(*obj.FieldMinUint16SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint16SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uint32slicepointer_min=2", + args: args{ + fieldName: "FieldMinUint32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUint32SlicePointer != nil && len(*obj.FieldMinUint32SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint32SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uint64slicepointer_min=2", + args: args{ + fieldName: "FieldMinUint64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUint64SlicePointer != nil && len(*obj.FieldMinUint64SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint64SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_float32slicepointer_min=2", + args: args{ + fieldName: "FieldMinFloat32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinFloat32SlicePointer != nil && len(*obj.FieldMinFloat32SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat32SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_float64slicepointer_min=2", + args: args{ + fieldName: "FieldMinFloat64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinFloat64SlicePointer != nil && len(*obj.FieldMinFloat64SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat64SlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_boolslicepointer_min=2", + args: args{ + fieldName: "FieldMinBoolSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinBoolSlicePointer != nil && len(*obj.FieldMinBoolSlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinBoolSlicePointer must have at least 2 elements")) +} +`, + }, + { + name: "min_stringmappointer_min=2", + args: args{ + fieldName: "FieldMinStringMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinStringMapPointer != nil && len(*obj.FieldMinStringMapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinStringMapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_intmappointer_min=2", + args: args{ + fieldName: "FieldMinIntMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinIntMapPointer != nil && len(*obj.FieldMinIntMapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinIntMapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_int8mappointer_min=2", + args: args{ + fieldName: "FieldMinInt8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinInt8MapPointer != nil && len(*obj.FieldMinInt8MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt8MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_int16mappointer_min=2", + args: args{ + fieldName: "FieldMinInt16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinInt16MapPointer != nil && len(*obj.FieldMinInt16MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt16MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_int32mappointer_min=2", + args: args{ + fieldName: "FieldMinInt32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinInt32MapPointer != nil && len(*obj.FieldMinInt32MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt32MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_int64mappointer_min=2", + args: args{ + fieldName: "FieldMinInt64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinInt64MapPointer != nil && len(*obj.FieldMinInt64MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt64MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uintmappointer_min=2", + args: args{ + fieldName: "FieldMinUintMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUintMapPointer != nil && len(*obj.FieldMinUintMapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUintMapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uint8mappointer_min=2", + args: args{ + fieldName: "FieldMinUint8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUint8MapPointer != nil && len(*obj.FieldMinUint8MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint8MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uint16mappointer_min=2", + args: args{ + fieldName: "FieldMinUint16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUint16MapPointer != nil && len(*obj.FieldMinUint16MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint16MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uint32mappointer_min=2", + args: args{ + fieldName: "FieldMinUint32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUint32MapPointer != nil && len(*obj.FieldMinUint32MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint32MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_uint64mappointer_min=2", + args: args{ + fieldName: "FieldMinUint64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinUint64MapPointer != nil && len(*obj.FieldMinUint64MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint64MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_float32mappointer_min=2", + args: args{ + fieldName: "FieldMinFloat32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinFloat32MapPointer != nil && len(*obj.FieldMinFloat32MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat32MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_float64mappointer_min=2", + args: args{ + fieldName: "FieldMinFloat64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinFloat64MapPointer != nil && len(*obj.FieldMinFloat64MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat64MapPointer must have at least 2 elements")) +} +`, + }, + { + name: "min_boolmappointer_min=2", + args: args{ + fieldName: "FieldMinBoolMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + fieldValidation: "min=2", + }, + want: `if !(obj.FieldMinBoolMapPointer != nil && len(*obj.FieldMinBoolMapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinBoolMapPointer must have at least 2 elements")) +} +`, + }, + { + name: "max_stringpointer_max=3", + args: args{ + fieldName: "FieldMaxStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "max=3", + }, + want: `if !(obj.FieldMaxStringPointer != nil && len(*obj.FieldMaxStringPointer) <= 3) { +errs = append(errs, types.NewValidationError("FieldMaxStringPointer length must be <= 3")) +} +`, + }, + { + name: "max_stringslicepointer_max=2", + args: args{ + fieldName: "FieldMaxStringSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxStringSlicePointer != nil && len(*obj.FieldMaxStringSlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxStringSlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_intslicepointer_max=2", + args: args{ + fieldName: "FieldMaxIntSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxIntSlicePointer != nil && len(*obj.FieldMaxIntSlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxIntSlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_int8slicepointer_max=2", + args: args{ + fieldName: "FieldMaxInt8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxInt8SlicePointer != nil && len(*obj.FieldMaxInt8SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt8SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_int16slicepointer_max=2", + args: args{ + fieldName: "FieldMaxInt16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxInt16SlicePointer != nil && len(*obj.FieldMaxInt16SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt16SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_int32slicepointer_max=2", + args: args{ + fieldName: "FieldMaxInt32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxInt32SlicePointer != nil && len(*obj.FieldMaxInt32SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt32SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_int64slicepointer_max=2", + args: args{ + fieldName: "FieldMaxInt64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxInt64SlicePointer != nil && len(*obj.FieldMaxInt64SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt64SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uintslicepointer_max=2", + args: args{ + fieldName: "FieldMaxUintSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUintSlicePointer != nil && len(*obj.FieldMaxUintSlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUintSlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uint8slicepointer_max=2", + args: args{ + fieldName: "FieldMaxUint8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUint8SlicePointer != nil && len(*obj.FieldMaxUint8SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint8SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uint16slicepointer_max=2", + args: args{ + fieldName: "FieldMaxUint16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUint16SlicePointer != nil && len(*obj.FieldMaxUint16SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint16SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uint32slicepointer_max=2", + args: args{ + fieldName: "FieldMaxUint32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUint32SlicePointer != nil && len(*obj.FieldMaxUint32SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint32SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uint64slicepointer_max=2", + args: args{ + fieldName: "FieldMaxUint64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUint64SlicePointer != nil && len(*obj.FieldMaxUint64SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint64SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_float32slicepointer_max=2", + args: args{ + fieldName: "FieldMaxFloat32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxFloat32SlicePointer != nil && len(*obj.FieldMaxFloat32SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat32SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_float64slicepointer_max=2", + args: args{ + fieldName: "FieldMaxFloat64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxFloat64SlicePointer != nil && len(*obj.FieldMaxFloat64SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat64SlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_boolslicepointer_max=2", + args: args{ + fieldName: "FieldMaxBoolSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxBoolSlicePointer != nil && len(*obj.FieldMaxBoolSlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxBoolSlicePointer must have at most 2 elements")) +} +`, + }, + { + name: "max_stringmappointer_max=2", + args: args{ + fieldName: "FieldMaxStringMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxStringMapPointer != nil && len(*obj.FieldMaxStringMapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxStringMapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_intmappointer_max=2", + args: args{ + fieldName: "FieldMaxIntMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxIntMapPointer != nil && len(*obj.FieldMaxIntMapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxIntMapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_int8mappointer_max=2", + args: args{ + fieldName: "FieldMaxInt8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxInt8MapPointer != nil && len(*obj.FieldMaxInt8MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt8MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_int16mappointer_max=2", + args: args{ + fieldName: "FieldMaxInt16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxInt16MapPointer != nil && len(*obj.FieldMaxInt16MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt16MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_int32mappointer_max=2", + args: args{ + fieldName: "FieldMaxInt32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxInt32MapPointer != nil && len(*obj.FieldMaxInt32MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt32MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_int64mappointer_max=2", + args: args{ + fieldName: "FieldMaxInt64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxInt64MapPointer != nil && len(*obj.FieldMaxInt64MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt64MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uintmappointer_max=2", + args: args{ + fieldName: "FieldMaxUintMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUintMapPointer != nil && len(*obj.FieldMaxUintMapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUintMapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uint8mappointer_max=2", + args: args{ + fieldName: "FieldMaxUint8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUint8MapPointer != nil && len(*obj.FieldMaxUint8MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint8MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uint16mappointer_max=2", + args: args{ + fieldName: "FieldMaxUint16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUint16MapPointer != nil && len(*obj.FieldMaxUint16MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint16MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uint32mappointer_max=2", + args: args{ + fieldName: "FieldMaxUint32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUint32MapPointer != nil && len(*obj.FieldMaxUint32MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint32MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_uint64mappointer_max=2", + args: args{ + fieldName: "FieldMaxUint64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxUint64MapPointer != nil && len(*obj.FieldMaxUint64MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint64MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_float32mappointer_max=2", + args: args{ + fieldName: "FieldMaxFloat32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxFloat32MapPointer != nil && len(*obj.FieldMaxFloat32MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat32MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_float64mappointer_max=2", + args: args{ + fieldName: "FieldMaxFloat64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + fieldValidation: "max=2", + }, + want: `if !(obj.FieldMaxFloat64MapPointer != nil && len(*obj.FieldMaxFloat64MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat64MapPointer must have at most 2 elements")) +} +`, + }, + { + name: "max_boolmappointer_max=1", + args: args{ + fieldName: "FieldMaxBoolMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + fieldValidation: "max=1", + }, + want: `if !(obj.FieldMaxBoolMapPointer != nil && len(*obj.FieldMaxBoolMapPointer) <= 1) { +errs = append(errs, types.NewValidationError("FieldMaxBoolMapPointer must have at most 1 elements")) +} +`, + }, + { + name: "eq_ignore_case_stringpointer_eq_ignore_case=abcde", + args: args{ + fieldName: "FieldEq_ignore_caseStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "eq_ignore_case=abcde", + }, + want: `if !(obj.FieldEq_ignore_caseStringPointer != nil && types.EqualFold(*obj.FieldEq_ignore_caseStringPointer, "abcde")) { +errs = append(errs, types.NewValidationError("FieldEq_ignore_caseStringPointer must be equal to 'abcde'")) +} +`, + }, + { + name: "neq_ignore_case_stringpointer_neq_ignore_case=abcde", + args: args{ + fieldName: "FieldNeq_ignore_caseStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "neq_ignore_case=abcde", + }, + want: `if !(obj.FieldNeq_ignore_caseStringPointer != nil && !types.EqualFold(*obj.FieldNeq_ignore_caseStringPointer, "abcde")) { +errs = append(errs, types.NewValidationError("FieldNeq_ignore_caseStringPointer must not be equal to 'abcde'")) +} +`, + }, + { + name: "len_stringpointer_len=2", + args: args{ + fieldName: "FieldLenStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenStringPointer != nil && len(*obj.FieldLenStringPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringPointer length must be 2")) +} +`, + }, + { + name: "len_stringslicepointer_len=2", + args: args{ + fieldName: "FieldLenStringSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenStringSlicePointer != nil && len(*obj.FieldLenStringSlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringSlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_intslicepointer_len=2", + args: args{ + fieldName: "FieldLenIntSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenIntSlicePointer != nil && len(*obj.FieldLenIntSlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenIntSlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_int8slicepointer_len=2", + args: args{ + fieldName: "FieldLenInt8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenInt8SlicePointer != nil && len(*obj.FieldLenInt8SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt8SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_int16slicepointer_len=2", + args: args{ + fieldName: "FieldLenInt16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenInt16SlicePointer != nil && len(*obj.FieldLenInt16SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt16SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_int32slicepointer_len=2", + args: args{ + fieldName: "FieldLenInt32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenInt32SlicePointer != nil && len(*obj.FieldLenInt32SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt32SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_int64slicepointer_len=2", + args: args{ + fieldName: "FieldLenInt64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenInt64SlicePointer != nil && len(*obj.FieldLenInt64SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt64SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uintslicepointer_len=2", + args: args{ + fieldName: "FieldLenUintSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUintSlicePointer != nil && len(*obj.FieldLenUintSlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUintSlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint8slicepointer_len=2", + args: args{ + fieldName: "FieldLenUint8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUint8SlicePointer != nil && len(*obj.FieldLenUint8SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint8SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint16slicepointer_len=2", + args: args{ + fieldName: "FieldLenUint16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUint16SlicePointer != nil && len(*obj.FieldLenUint16SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint16SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint32slicepointer_len=2", + args: args{ + fieldName: "FieldLenUint32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUint32SlicePointer != nil && len(*obj.FieldLenUint32SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint32SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint64slicepointer_len=2", + args: args{ + fieldName: "FieldLenUint64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUint64SlicePointer != nil && len(*obj.FieldLenUint64SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint64SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_float32slicepointer_len=2", + args: args{ + fieldName: "FieldLenFloat32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenFloat32SlicePointer != nil && len(*obj.FieldLenFloat32SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat32SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_float64slicepointer_len=2", + args: args{ + fieldName: "FieldLenFloat64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenFloat64SlicePointer != nil && len(*obj.FieldLenFloat64SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat64SlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_boolslicepointer_len=2", + args: args{ + fieldName: "FieldLenBoolSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenBoolSlicePointer != nil && len(*obj.FieldLenBoolSlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenBoolSlicePointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_stringmappointer_len=2", + args: args{ + fieldName: "FieldLenStringMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenStringMapPointer != nil && len(*obj.FieldLenStringMapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringMapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_intmappointer_len=2", + args: args{ + fieldName: "FieldLenIntMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenIntMapPointer != nil && len(*obj.FieldLenIntMapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenIntMapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_int8mappointer_len=2", + args: args{ + fieldName: "FieldLenInt8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenInt8MapPointer != nil && len(*obj.FieldLenInt8MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt8MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_int16mappointer_len=2", + args: args{ + fieldName: "FieldLenInt16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenInt16MapPointer != nil && len(*obj.FieldLenInt16MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt16MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_int32mappointer_len=2", + args: args{ + fieldName: "FieldLenInt32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenInt32MapPointer != nil && len(*obj.FieldLenInt32MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt32MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_int64mappointer_len=2", + args: args{ + fieldName: "FieldLenInt64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenInt64MapPointer != nil && len(*obj.FieldLenInt64MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt64MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uintmappointer_len=2", + args: args{ + fieldName: "FieldLenUintMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUintMapPointer != nil && len(*obj.FieldLenUintMapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUintMapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint8mappointer_len=2", + args: args{ + fieldName: "FieldLenUint8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUint8MapPointer != nil && len(*obj.FieldLenUint8MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint8MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint16mappointer_len=2", + args: args{ + fieldName: "FieldLenUint16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUint16MapPointer != nil && len(*obj.FieldLenUint16MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint16MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint32mappointer_len=2", + args: args{ + fieldName: "FieldLenUint32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUint32MapPointer != nil && len(*obj.FieldLenUint32MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint32MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_uint64mappointer_len=2", + args: args{ + fieldName: "FieldLenUint64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenUint64MapPointer != nil && len(*obj.FieldLenUint64MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint64MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_float32mappointer_len=2", + args: args{ + fieldName: "FieldLenFloat32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenFloat32MapPointer != nil && len(*obj.FieldLenFloat32MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat32MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_float64mappointer_len=2", + args: args{ + fieldName: "FieldLenFloat64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenFloat64MapPointer != nil && len(*obj.FieldLenFloat64MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat64MapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "len_boolmappointer_len=2", + args: args{ + fieldName: "FieldLenBoolMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + fieldValidation: "len=2", + }, + want: `if !(obj.FieldLenBoolMapPointer != nil && len(*obj.FieldLenBoolMapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenBoolMapPointer must have exactly 2 elements")) +} +`, + }, + { + name: "in_stringpointer_in=ab cd ef", + args: args{ + fieldName: "FieldInStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "in=ab cd ef", + }, + want: `if !((obj.FieldInStringPointer != nil && *obj.FieldInStringPointer == "ab") || (obj.FieldInStringPointer != nil && *obj.FieldInStringPointer == "cd") || (obj.FieldInStringPointer != nil && *obj.FieldInStringPointer == "ef")) { +errs = append(errs, types.NewValidationError("FieldInStringPointer must be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "in_intpointer_in=12 34 56", + args: args{ + fieldName: "FieldInIntPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInIntPointer != nil && *obj.FieldInIntPointer == 12) || (obj.FieldInIntPointer != nil && *obj.FieldInIntPointer == 34) || (obj.FieldInIntPointer != nil && *obj.FieldInIntPointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInIntPointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int8pointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInInt8Pointer != nil && *obj.FieldInInt8Pointer == 12) || (obj.FieldInInt8Pointer != nil && *obj.FieldInInt8Pointer == 34) || (obj.FieldInInt8Pointer != nil && *obj.FieldInInt8Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInInt8Pointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int16pointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInInt16Pointer != nil && *obj.FieldInInt16Pointer == 12) || (obj.FieldInInt16Pointer != nil && *obj.FieldInInt16Pointer == 34) || (obj.FieldInInt16Pointer != nil && *obj.FieldInInt16Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInInt16Pointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int32pointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInInt32Pointer != nil && *obj.FieldInInt32Pointer == 12) || (obj.FieldInInt32Pointer != nil && *obj.FieldInInt32Pointer == 34) || (obj.FieldInInt32Pointer != nil && *obj.FieldInInt32Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInInt32Pointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int64pointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInInt64Pointer != nil && *obj.FieldInInt64Pointer == 12) || (obj.FieldInInt64Pointer != nil && *obj.FieldInInt64Pointer == 34) || (obj.FieldInInt64Pointer != nil && *obj.FieldInInt64Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInInt64Pointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uintpointer_in=12 34 56", + args: args{ + fieldName: "FieldInUintPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInUintPointer != nil && *obj.FieldInUintPointer == 12) || (obj.FieldInUintPointer != nil && *obj.FieldInUintPointer == 34) || (obj.FieldInUintPointer != nil && *obj.FieldInUintPointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUintPointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint8pointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInUint8Pointer != nil && *obj.FieldInUint8Pointer == 12) || (obj.FieldInUint8Pointer != nil && *obj.FieldInUint8Pointer == 34) || (obj.FieldInUint8Pointer != nil && *obj.FieldInUint8Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUint8Pointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint16pointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInUint16Pointer != nil && *obj.FieldInUint16Pointer == 12) || (obj.FieldInUint16Pointer != nil && *obj.FieldInUint16Pointer == 34) || (obj.FieldInUint16Pointer != nil && *obj.FieldInUint16Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUint16Pointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint32pointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInUint32Pointer != nil && *obj.FieldInUint32Pointer == 12) || (obj.FieldInUint32Pointer != nil && *obj.FieldInUint32Pointer == 34) || (obj.FieldInUint32Pointer != nil && *obj.FieldInUint32Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUint32Pointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint64pointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !((obj.FieldInUint64Pointer != nil && *obj.FieldInUint64Pointer == 12) || (obj.FieldInUint64Pointer != nil && *obj.FieldInUint64Pointer == 34) || (obj.FieldInUint64Pointer != nil && *obj.FieldInUint64Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUint64Pointer must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_float32pointer_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !((obj.FieldInFloat32Pointer != nil && *obj.FieldInFloat32Pointer == 11.11) || (obj.FieldInFloat32Pointer != nil && *obj.FieldInFloat32Pointer == 22.22) || (obj.FieldInFloat32Pointer != nil && *obj.FieldInFloat32Pointer == 33.33)) { +errs = append(errs, types.NewValidationError("FieldInFloat32Pointer must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_float64pointer_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !((obj.FieldInFloat64Pointer != nil && *obj.FieldInFloat64Pointer == 11.11) || (obj.FieldInFloat64Pointer != nil && *obj.FieldInFloat64Pointer == 22.22) || (obj.FieldInFloat64Pointer != nil && *obj.FieldInFloat64Pointer == 33.33)) { +errs = append(errs, types.NewValidationError("FieldInFloat64Pointer must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_boolpointer_in=true", + args: args{ + fieldName: "FieldInBoolPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + fieldValidation: "in=true", + }, + want: `if !((obj.FieldInBoolPointer != nil && *obj.FieldInBoolPointer == true)) { +errs = append(errs, types.NewValidationError("FieldInBoolPointer must be one of 'true'")) +} +`, + }, + { + name: "in_stringslicepointer_in=ab cd ef", + args: args{ + fieldName: "FieldInStringSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + fieldValidation: "in=ab cd ef", + }, + want: `if !(obj.FieldInStringSlicePointer != nil && types.SliceOnlyContains(*obj.FieldInStringSlicePointer, []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldInStringSlicePointer elements must be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "in_intslicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInIntSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInIntSlicePointer != nil && types.SliceOnlyContains(*obj.FieldInIntSlicePointer, []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInIntSlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int8slicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt8SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInInt8SlicePointer, []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt8SlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int16slicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt16SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInInt16SlicePointer, []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt16SlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int32slicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt32SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInInt32SlicePointer, []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt32SlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int64slicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt64SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInInt64SlicePointer, []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt64SlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uintslicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInUintSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUintSlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUintSlicePointer, []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUintSlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint8slicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint8SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUint8SlicePointer, []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint8SlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint16slicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint16SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUint16SlicePointer, []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint16SlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint32slicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint32SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUint32SlicePointer, []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint32SlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint64slicepointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint64SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUint64SlicePointer, []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint64SlicePointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_float32slicepointer_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(obj.FieldInFloat32SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInFloat32SlicePointer, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32SlicePointer elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_float64slicepointer_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(obj.FieldInFloat64SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInFloat64SlicePointer, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64SlicePointer elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_boolslicepointer_in=true", + args: args{ + fieldName: "FieldInBoolSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + fieldValidation: "in=true", + }, + want: `if !(obj.FieldInBoolSlicePointer != nil && types.SliceOnlyContains(*obj.FieldInBoolSlicePointer, []bool{true})) { +errs = append(errs, types.NewValidationError("FieldInBoolSlicePointer elements must be one of 'true'")) +} +`, + }, + { + name: "in_stringarraypointer_in=ab cd ef", + args: args{ + fieldName: "FieldInStringArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "string", Size: "3"}, + fieldValidation: "in=ab cd ef", + }, + want: `if !(obj.FieldInStringArrayPointer != nil && types.SliceOnlyContains(obj.FieldInStringArrayPointer[:], []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldInStringArrayPointer elements must be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "in_intarraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInIntArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInIntArrayPointer != nil && types.SliceOnlyContains(obj.FieldInIntArrayPointer[:], []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInIntArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int8arraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt8ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int8", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt8ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInInt8ArrayPointer[:], []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt8ArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int16arraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt16ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int16", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt16ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInInt16ArrayPointer[:], []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt16ArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int32arraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt32ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int32", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt32ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInInt32ArrayPointer[:], []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt32ArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_int64arraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInInt64ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int64", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInInt64ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInInt64ArrayPointer[:], []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt64ArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uintarraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInUintArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUintArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUintArrayPointer[:], []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUintArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint8arraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint8ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint8", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint8ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUint8ArrayPointer[:], []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint8ArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint16arraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint16ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint16", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint16ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUint16ArrayPointer[:], []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint16ArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint32arraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint32ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint32", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint32ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUint32ArrayPointer[:], []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint32ArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_uint64arraypointer_in=12 34 56", + args: args{ + fieldName: "FieldInUint64ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint64", Size: "3"}, + fieldValidation: "in=12 34 56", + }, + want: `if !(obj.FieldInUint64ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUint64ArrayPointer[:], []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint64ArrayPointer elements must be one of '12' '34' '56'")) +} +`, + }, + { + name: "in_float32arraypointer_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat32ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "float32", Size: "3"}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(obj.FieldInFloat32ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInFloat32ArrayPointer[:], []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32ArrayPointer elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_float64arraypointer_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat64ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "float64", Size: "3"}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(obj.FieldInFloat64ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInFloat64ArrayPointer[:], []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64ArrayPointer elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_boolarraypointer_in=true", + args: args{ + fieldName: "FieldInBoolArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "bool", Size: "3"}, + fieldValidation: "in=true", + }, + want: `if !(obj.FieldInBoolArrayPointer != nil && types.SliceOnlyContains(obj.FieldInBoolArrayPointer[:], []bool{true})) { +errs = append(errs, types.NewValidationError("FieldInBoolArrayPointer elements must be one of 'true'")) +} +`, + }, + { + name: "in_stringmappointer_in=a b c", + args: args{ + fieldName: "FieldInStringMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + fieldValidation: "in=a b c", + }, + want: `if !(obj.FieldInStringMapPointer != nil && types.MapOnlyContains(*obj.FieldInStringMapPointer, []string{"a", "b", "c"})) { +errs = append(errs, types.NewValidationError("FieldInStringMapPointer elements must be one of 'a' 'b' 'c'")) +} +`, + }, + { + name: "in_intmappointer_in=1 2 3", + args: args{ + fieldName: "FieldInIntMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInIntMapPointer != nil && types.MapOnlyContains(*obj.FieldInIntMapPointer, []int{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInIntMapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_int8mappointer_in=1 2 3", + args: args{ + fieldName: "FieldInInt8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInInt8MapPointer != nil && types.MapOnlyContains(*obj.FieldInInt8MapPointer, []int8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt8MapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_int16mappointer_in=1 2 3", + args: args{ + fieldName: "FieldInInt16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInInt16MapPointer != nil && types.MapOnlyContains(*obj.FieldInInt16MapPointer, []int16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt16MapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_int32mappointer_in=1 2 3", + args: args{ + fieldName: "FieldInInt32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInInt32MapPointer != nil && types.MapOnlyContains(*obj.FieldInInt32MapPointer, []int32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt32MapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_int64mappointer_in=1 2 3", + args: args{ + fieldName: "FieldInInt64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInInt64MapPointer != nil && types.MapOnlyContains(*obj.FieldInInt64MapPointer, []int64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt64MapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uintmappointer_in=1 2 3", + args: args{ + fieldName: "FieldInUintMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInUintMapPointer != nil && types.MapOnlyContains(*obj.FieldInUintMapPointer, []uint{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUintMapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uint8mappointer_in=1 2 3", + args: args{ + fieldName: "FieldInUint8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInUint8MapPointer != nil && types.MapOnlyContains(*obj.FieldInUint8MapPointer, []uint8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint8MapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uint16mappointer_in=1 2 3", + args: args{ + fieldName: "FieldInUint16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInUint16MapPointer != nil && types.MapOnlyContains(*obj.FieldInUint16MapPointer, []uint16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint16MapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uint32mappointer_in=1 2 3", + args: args{ + fieldName: "FieldInUint32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInUint32MapPointer != nil && types.MapOnlyContains(*obj.FieldInUint32MapPointer, []uint32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint32MapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_uint64mappointer_in=1 2 3", + args: args{ + fieldName: "FieldInUint64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + fieldValidation: "in=1 2 3", + }, + want: `if !(obj.FieldInUint64MapPointer != nil && types.MapOnlyContains(*obj.FieldInUint64MapPointer, []uint64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint64MapPointer elements must be one of '1' '2' '3'")) +} +`, + }, + { + name: "in_float32mappointer_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(obj.FieldInFloat32MapPointer != nil && types.MapOnlyContains(*obj.FieldInFloat32MapPointer, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32MapPointer elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_float64mappointer_in=11.11 22.22 33.33", + args: args{ + fieldName: "FieldInFloat64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + fieldValidation: "in=11.11 22.22 33.33", + }, + want: `if !(obj.FieldInFloat64MapPointer != nil && types.MapOnlyContains(*obj.FieldInFloat64MapPointer, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64MapPointer elements must be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "in_boolmappointer_in=false", + args: args{ + fieldName: "FieldInBoolMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + fieldValidation: "in=false", + }, + want: `if !(obj.FieldInBoolMapPointer != nil && types.MapOnlyContains(*obj.FieldInBoolMapPointer, []bool{false})) { +errs = append(errs, types.NewValidationError("FieldInBoolMapPointer elements must be one of 'false'")) +} +`, + }, + { + name: "nin_stringpointer_nin=ab cd ef", + args: args{ + fieldName: "FieldNinStringPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + fieldValidation: "nin=ab cd ef", + }, + want: `if !((obj.FieldNinStringPointer != nil && *obj.FieldNinStringPointer != "ab") && (obj.FieldNinStringPointer != nil && *obj.FieldNinStringPointer != "cd") && (obj.FieldNinStringPointer != nil && *obj.FieldNinStringPointer != "ef")) { +errs = append(errs, types.NewValidationError("FieldNinStringPointer must not be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "nin_intpointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinIntPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinIntPointer != nil && *obj.FieldNinIntPointer != 12) && (obj.FieldNinIntPointer != nil && *obj.FieldNinIntPointer != 34) && (obj.FieldNinIntPointer != nil && *obj.FieldNinIntPointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinIntPointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int8pointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinInt8Pointer != nil && *obj.FieldNinInt8Pointer != 12) && (obj.FieldNinInt8Pointer != nil && *obj.FieldNinInt8Pointer != 34) && (obj.FieldNinInt8Pointer != nil && *obj.FieldNinInt8Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinInt8Pointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int16pointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinInt16Pointer != nil && *obj.FieldNinInt16Pointer != 12) && (obj.FieldNinInt16Pointer != nil && *obj.FieldNinInt16Pointer != 34) && (obj.FieldNinInt16Pointer != nil && *obj.FieldNinInt16Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinInt16Pointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int32pointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinInt32Pointer != nil && *obj.FieldNinInt32Pointer != 12) && (obj.FieldNinInt32Pointer != nil && *obj.FieldNinInt32Pointer != 34) && (obj.FieldNinInt32Pointer != nil && *obj.FieldNinInt32Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinInt32Pointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int64pointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinInt64Pointer != nil && *obj.FieldNinInt64Pointer != 12) && (obj.FieldNinInt64Pointer != nil && *obj.FieldNinInt64Pointer != 34) && (obj.FieldNinInt64Pointer != nil && *obj.FieldNinInt64Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinInt64Pointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uintpointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUintPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinUintPointer != nil && *obj.FieldNinUintPointer != 12) && (obj.FieldNinUintPointer != nil && *obj.FieldNinUintPointer != 34) && (obj.FieldNinUintPointer != nil && *obj.FieldNinUintPointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUintPointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint8pointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint8Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinUint8Pointer != nil && *obj.FieldNinUint8Pointer != 12) && (obj.FieldNinUint8Pointer != nil && *obj.FieldNinUint8Pointer != 34) && (obj.FieldNinUint8Pointer != nil && *obj.FieldNinUint8Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUint8Pointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint16pointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint16Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinUint16Pointer != nil && *obj.FieldNinUint16Pointer != 12) && (obj.FieldNinUint16Pointer != nil && *obj.FieldNinUint16Pointer != 34) && (obj.FieldNinUint16Pointer != nil && *obj.FieldNinUint16Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUint16Pointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint32pointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinUint32Pointer != nil && *obj.FieldNinUint32Pointer != 12) && (obj.FieldNinUint32Pointer != nil && *obj.FieldNinUint32Pointer != 34) && (obj.FieldNinUint32Pointer != nil && *obj.FieldNinUint32Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUint32Pointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint64pointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !((obj.FieldNinUint64Pointer != nil && *obj.FieldNinUint64Pointer != 12) && (obj.FieldNinUint64Pointer != nil && *obj.FieldNinUint64Pointer != 34) && (obj.FieldNinUint64Pointer != nil && *obj.FieldNinUint64Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUint64Pointer must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_float32pointer_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat32Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !((obj.FieldNinFloat32Pointer != nil && *obj.FieldNinFloat32Pointer != 11.11) && (obj.FieldNinFloat32Pointer != nil && *obj.FieldNinFloat32Pointer != 22.22) && (obj.FieldNinFloat32Pointer != nil && *obj.FieldNinFloat32Pointer != 33.33)) { +errs = append(errs, types.NewValidationError("FieldNinFloat32Pointer must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_float64pointer_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat64Pointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !((obj.FieldNinFloat64Pointer != nil && *obj.FieldNinFloat64Pointer != 11.11) && (obj.FieldNinFloat64Pointer != nil && *obj.FieldNinFloat64Pointer != 22.22) && (obj.FieldNinFloat64Pointer != nil && *obj.FieldNinFloat64Pointer != 33.33)) { +errs = append(errs, types.NewValidationError("FieldNinFloat64Pointer must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_boolpointer_nin=true", + args: args{ + fieldName: "FieldNinBoolPointer", + fieldType: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + fieldValidation: "nin=true", + }, + want: `if !((obj.FieldNinBoolPointer != nil && *obj.FieldNinBoolPointer != true)) { +errs = append(errs, types.NewValidationError("FieldNinBoolPointer must not be one of 'true'")) +} +`, + }, + { + name: "nin_stringslicepointer_nin=ab cd ef", + args: args{ + fieldName: "FieldNinStringSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + fieldValidation: "nin=ab cd ef", + }, + want: `if !(obj.FieldNinStringSlicePointer != nil && types.SliceNotContains(*obj.FieldNinStringSlicePointer, []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldNinStringSlicePointer elements must not be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "nin_intslicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinIntSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinIntSlicePointer != nil && types.SliceNotContains(*obj.FieldNinIntSlicePointer, []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinIntSlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int8slicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt8SlicePointer != nil && types.SliceNotContains(*obj.FieldNinInt8SlicePointer, []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt8SlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int16slicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt16SlicePointer != nil && types.SliceNotContains(*obj.FieldNinInt16SlicePointer, []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt16SlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int32slicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt32SlicePointer != nil && types.SliceNotContains(*obj.FieldNinInt32SlicePointer, []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt32SlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int64slicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt64SlicePointer != nil && types.SliceNotContains(*obj.FieldNinInt64SlicePointer, []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt64SlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uintslicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUintSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUintSlicePointer != nil && types.SliceNotContains(*obj.FieldNinUintSlicePointer, []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUintSlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint8slicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint8SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint8SlicePointer != nil && types.SliceNotContains(*obj.FieldNinUint8SlicePointer, []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint8SlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint16slicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint16SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint16SlicePointer != nil && types.SliceNotContains(*obj.FieldNinUint16SlicePointer, []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint16SlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint32slicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint32SlicePointer != nil && types.SliceNotContains(*obj.FieldNinUint32SlicePointer, []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint32SlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint64slicepointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint64SlicePointer != nil && types.SliceNotContains(*obj.FieldNinUint64SlicePointer, []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint64SlicePointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_float32slicepointer_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat32SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(obj.FieldNinFloat32SlicePointer != nil && types.SliceNotContains(*obj.FieldNinFloat32SlicePointer, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32SlicePointer elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_float64slicepointer_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat64SlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(obj.FieldNinFloat64SlicePointer != nil && types.SliceNotContains(*obj.FieldNinFloat64SlicePointer, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64SlicePointer elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_boolslicepointer_nin=true", + args: args{ + fieldName: "FieldNinBoolSlicePointer", + fieldType: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + fieldValidation: "nin=true", + }, + want: `if !(obj.FieldNinBoolSlicePointer != nil && types.SliceNotContains(*obj.FieldNinBoolSlicePointer, []bool{true})) { +errs = append(errs, types.NewValidationError("FieldNinBoolSlicePointer elements must not be one of 'true'")) +} +`, + }, + { + name: "nin_stringarraypointer_nin=ab cd ef", + args: args{ + fieldName: "FieldNinStringArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "string", Size: "3"}, + fieldValidation: "nin=ab cd ef", + }, + want: `if !(obj.FieldNinStringArrayPointer != nil && types.SliceNotContains(obj.FieldNinStringArrayPointer[:], []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldNinStringArrayPointer elements must not be one of 'ab' 'cd' 'ef'")) +} +`, + }, + { + name: "nin_intarraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinIntArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinIntArrayPointer != nil && types.SliceNotContains(obj.FieldNinIntArrayPointer[:], []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinIntArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int8arraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt8ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int8", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt8ArrayPointer != nil && types.SliceNotContains(obj.FieldNinInt8ArrayPointer[:], []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt8ArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int16arraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt16ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int16", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt16ArrayPointer != nil && types.SliceNotContains(obj.FieldNinInt16ArrayPointer[:], []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt16ArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int32arraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt32ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int32", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt32ArrayPointer != nil && types.SliceNotContains(obj.FieldNinInt32ArrayPointer[:], []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt32ArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_int64arraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinInt64ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "int64", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinInt64ArrayPointer != nil && types.SliceNotContains(obj.FieldNinInt64ArrayPointer[:], []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt64ArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uintarraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUintArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUintArrayPointer != nil && types.SliceNotContains(obj.FieldNinUintArrayPointer[:], []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUintArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint8arraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint8ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint8", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint8ArrayPointer != nil && types.SliceNotContains(obj.FieldNinUint8ArrayPointer[:], []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint8ArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint16arraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint16ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint16", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint16ArrayPointer != nil && types.SliceNotContains(obj.FieldNinUint16ArrayPointer[:], []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint16ArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint32arraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint32ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint32", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint32ArrayPointer != nil && types.SliceNotContains(obj.FieldNinUint32ArrayPointer[:], []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint32ArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_uint64arraypointer_nin=12 34 56", + args: args{ + fieldName: "FieldNinUint64ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "uint64", Size: "3"}, + fieldValidation: "nin=12 34 56", + }, + want: `if !(obj.FieldNinUint64ArrayPointer != nil && types.SliceNotContains(obj.FieldNinUint64ArrayPointer[:], []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint64ArrayPointer elements must not be one of '12' '34' '56'")) +} +`, + }, + { + name: "nin_float32arraypointer_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat32ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "float32", Size: "3"}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(obj.FieldNinFloat32ArrayPointer != nil && types.SliceNotContains(obj.FieldNinFloat32ArrayPointer[:], []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32ArrayPointer elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_float64arraypointer_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat64ArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "float64", Size: "3"}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(obj.FieldNinFloat64ArrayPointer != nil && types.SliceNotContains(obj.FieldNinFloat64ArrayPointer[:], []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64ArrayPointer elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_boolarraypointer_nin=true", + args: args{ + fieldName: "FieldNinBoolArrayPointer", + fieldType: common.FieldType{ComposedType: "*[N]", BaseType: "bool", Size: "3"}, + fieldValidation: "nin=true", + }, + want: `if !(obj.FieldNinBoolArrayPointer != nil && types.SliceNotContains(obj.FieldNinBoolArrayPointer[:], []bool{true})) { +errs = append(errs, types.NewValidationError("FieldNinBoolArrayPointer elements must not be one of 'true'")) +} +`, + }, + { + name: "nin_stringmappointer_nin=a b c", + args: args{ + fieldName: "FieldNinStringMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + fieldValidation: "nin=a b c", + }, + want: `if !(obj.FieldNinStringMapPointer != nil && types.MapNotContains(*obj.FieldNinStringMapPointer, []string{"a", "b", "c"})) { +errs = append(errs, types.NewValidationError("FieldNinStringMapPointer elements must not be one of 'a' 'b' 'c'")) +} +`, + }, + { + name: "nin_intmappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinIntMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinIntMapPointer != nil && types.MapNotContains(*obj.FieldNinIntMapPointer, []int{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinIntMapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_int8mappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinInt8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinInt8MapPointer != nil && types.MapNotContains(*obj.FieldNinInt8MapPointer, []int8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt8MapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_int16mappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinInt16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinInt16MapPointer != nil && types.MapNotContains(*obj.FieldNinInt16MapPointer, []int16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt16MapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_int32mappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinInt32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinInt32MapPointer != nil && types.MapNotContains(*obj.FieldNinInt32MapPointer, []int32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt32MapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_int64mappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinInt64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinInt64MapPointer != nil && types.MapNotContains(*obj.FieldNinInt64MapPointer, []int64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt64MapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uintmappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinUintMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinUintMapPointer != nil && types.MapNotContains(*obj.FieldNinUintMapPointer, []uint{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUintMapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uint8mappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinUint8MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinUint8MapPointer != nil && types.MapNotContains(*obj.FieldNinUint8MapPointer, []uint8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint8MapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uint16mappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinUint16MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinUint16MapPointer != nil && types.MapNotContains(*obj.FieldNinUint16MapPointer, []uint16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint16MapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uint32mappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinUint32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinUint32MapPointer != nil && types.MapNotContains(*obj.FieldNinUint32MapPointer, []uint32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint32MapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_uint64mappointer_nin=1 2 3", + args: args{ + fieldName: "FieldNinUint64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + fieldValidation: "nin=1 2 3", + }, + want: `if !(obj.FieldNinUint64MapPointer != nil && types.MapNotContains(*obj.FieldNinUint64MapPointer, []uint64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint64MapPointer elements must not be one of '1' '2' '3'")) +} +`, + }, + { + name: "nin_float32mappointer_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat32MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(obj.FieldNinFloat32MapPointer != nil && types.MapNotContains(*obj.FieldNinFloat32MapPointer, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32MapPointer elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_float64mappointer_nin=11.11 22.22 33.33", + args: args{ + fieldName: "FieldNinFloat64MapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + fieldValidation: "nin=11.11 22.22 33.33", + }, + want: `if !(obj.FieldNinFloat64MapPointer != nil && types.MapNotContains(*obj.FieldNinFloat64MapPointer, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64MapPointer elements must not be one of '11.11' '22.22' '33.33'")) +} +`, + }, + { + name: "nin_boolmappointer_nin=false", + args: args{ + fieldName: "FieldNinBoolMapPointer", + fieldType: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + fieldValidation: "nin=false", + }, + want: `if !(obj.FieldNinBoolMapPointer != nil && types.MapNotContains(*obj.FieldNinBoolMapPointer, []bool{false})) { +errs = append(errs, types.NewValidationError("FieldNinBoolMapPointer elements must not be one of 'false'")) +} +`, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gv := GenValidations{} + validation := AssertParserValidation(t, tt.args.fieldValidation) + got, err := gv.BuildValidationCode(tt.args.fieldName, tt.args.fieldType, []*analyzer.Validation{validation}) + if err != nil { + t.Errorf("BuildValidationCode() error = %v, wantErr %v", err, nil) + return + } + if got != tt.want { + t.Errorf("BuildValidationCode() = %v, want %v", got, tt.want) + } + }) + } +} From 581fa9a3edda74e0786f015153e238424f059b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 26 Oct 2025 13:07:21 -0300 Subject: [PATCH 06/31] chore: makefile rule to build generated tests and move to the correct path --- Makefile | 7 +++++-- ...ter_tests.go => generated_endtoend_no_pointer_tests.go} | 0 ...ointer_tests.go => generated_endtoend_pointer_tests.go} | 0 3 files changed, 5 insertions(+), 2 deletions(-) rename tests/endtoend/{generated_no_pointer_tests.go => generated_endtoend_no_pointer_tests.go} (100%) rename tests/endtoend/{generated_pointer_tests.go => generated_endtoend_pointer_tests.go} (100%) diff --git a/Makefile b/Makefile index d0b36e5..c85b537 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean unittests benchtests build endtoendtests cmpbenchtests +.PHONY: clean unittests benchtests build endtoendtests cmpbenchtests testgen setup lint BIN_DIR=bin BIN_NAME=validgen @@ -29,10 +29,13 @@ build: clean @echo "Building" go build -o $(VALIDGEN_BIN) . +testgen: + @echo "Generating tests" + cd testgen/; rm -f generated_*.go; go run *.go; mv generated_endtoend_*tests.go ../tests/endtoend/; mv generated_validation_*_test.go ../internal/codegenerator/ + endtoendtests: build @echo "Running endtoend tests" find tests/endtoend/ -name 'validator__.go' -exec rm \{} \; - cd tests/endtoend/generate_tests/; rm -f generated*tests.go; go run *.go; mv generated*tests.go .. $(VALIDGEN_BIN) tests/endtoend cd tests/endtoend; go run . diff --git a/tests/endtoend/generated_no_pointer_tests.go b/tests/endtoend/generated_endtoend_no_pointer_tests.go similarity index 100% rename from tests/endtoend/generated_no_pointer_tests.go rename to tests/endtoend/generated_endtoend_no_pointer_tests.go diff --git a/tests/endtoend/generated_pointer_tests.go b/tests/endtoend/generated_endtoend_pointer_tests.go similarity index 100% rename from tests/endtoend/generated_pointer_tests.go rename to tests/endtoend/generated_endtoend_pointer_tests.go From 98b323abf1d8018a6844f1c246d2a86e11ef10a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 26 Oct 2025 19:14:13 -0300 Subject: [PATCH 07/31] chore: add DO NOT EDIT to all templates --- .../codegenerator/generated_validation_code_no_pointer_test.go | 2 ++ .../codegenerator/generated_validation_code_pointer_test.go | 2 ++ testgen/build_validation_code_test.tpl | 2 ++ 3 files changed, 6 insertions(+) diff --git a/internal/codegenerator/generated_validation_code_no_pointer_test.go b/internal/codegenerator/generated_validation_code_no_pointer_test.go index ed605a7..7920045 100644 --- a/internal/codegenerator/generated_validation_code_no_pointer_test.go +++ b/internal/codegenerator/generated_validation_code_no_pointer_test.go @@ -1,3 +1,5 @@ +// Code generated by TestGen. DO NOT EDIT. + package codegenerator import ( diff --git a/internal/codegenerator/generated_validation_code_pointer_test.go b/internal/codegenerator/generated_validation_code_pointer_test.go index 2ac92e6..6fa3895 100644 --- a/internal/codegenerator/generated_validation_code_pointer_test.go +++ b/internal/codegenerator/generated_validation_code_pointer_test.go @@ -1,3 +1,5 @@ +// Code generated by TestGen. DO NOT EDIT. + package codegenerator import ( diff --git a/testgen/build_validation_code_test.tpl b/testgen/build_validation_code_test.tpl index c80c514..2068329 100644 --- a/testgen/build_validation_code_test.tpl +++ b/testgen/build_validation_code_test.tpl @@ -1,3 +1,5 @@ +// Code generated by TestGen. DO NOT EDIT. + package codegenerator import ( From 55919422fa2b9f59ded95ad9e9d1a55a9cb375f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 26 Oct 2025 19:16:25 -0300 Subject: [PATCH 08/31] chore: fix DO NOT EDIT header --- testgen/no_pointer_tests.tpl | 2 +- testgen/pointer_tests.tpl | 2 +- tests/endtoend/generated_endtoend_no_pointer_tests.go | 2 +- tests/endtoend/generated_endtoend_pointer_tests.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testgen/no_pointer_tests.tpl b/testgen/no_pointer_tests.tpl index 8badfdf..4686e3d 100644 --- a/testgen/no_pointer_tests.tpl +++ b/testgen/no_pointer_tests.tpl @@ -1,4 +1,4 @@ -// Code generated by TestGenerator. DO NOT EDIT. +// Code generated by TestGen. DO NOT EDIT. package main diff --git a/testgen/pointer_tests.tpl b/testgen/pointer_tests.tpl index 6528758..d67bddc 100644 --- a/testgen/pointer_tests.tpl +++ b/testgen/pointer_tests.tpl @@ -1,4 +1,4 @@ -// Code generated by TestGenerator. DO NOT EDIT. +// Code generated by TestGen. DO NOT EDIT. package main diff --git a/tests/endtoend/generated_endtoend_no_pointer_tests.go b/tests/endtoend/generated_endtoend_no_pointer_tests.go index cc8c5b6..30d6531 100644 --- a/tests/endtoend/generated_endtoend_no_pointer_tests.go +++ b/tests/endtoend/generated_endtoend_no_pointer_tests.go @@ -1,4 +1,4 @@ -// Code generated by TestGenerator. DO NOT EDIT. +// Code generated by TestGen. DO NOT EDIT. package main diff --git a/tests/endtoend/generated_endtoend_pointer_tests.go b/tests/endtoend/generated_endtoend_pointer_tests.go index 778456c..fadd056 100644 --- a/tests/endtoend/generated_endtoend_pointer_tests.go +++ b/tests/endtoend/generated_endtoend_pointer_tests.go @@ -1,4 +1,4 @@ -// Code generated by TestGenerator. DO NOT EDIT. +// Code generated by TestGen. DO NOT EDIT. package main From 47d14f65f5daecba937f3736ce85a90ca962d376 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 26 Oct 2025 19:17:34 -0300 Subject: [PATCH 09/31] chore: better func name --- testgen/generate_validation_code_tests.go | 2 +- testgen/generate_validation_types_tests.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testgen/generate_validation_code_tests.go b/testgen/generate_validation_code_tests.go index 6eadbcc..44531a3 100644 --- a/testgen/generate_validation_code_tests.go +++ b/testgen/generate_validation_code_tests.go @@ -28,7 +28,7 @@ type ValidationCodeTestCase struct { ExpectedCode string } -func generateValidationCodeTests() { +func generateValidationCodeUnitTests() { generateValidationCodeTestsFile("build_validation_code_test.tpl", "generated_validation_code_no_pointer_test.go", false) generateValidationCodeTestsFile("build_validation_code_test.tpl", "generated_validation_code_pointer_test.go", true) } diff --git a/testgen/generate_validation_types_tests.go b/testgen/generate_validation_types_tests.go index 3c84647..3984617 100644 --- a/testgen/generate_validation_types_tests.go +++ b/testgen/generate_validation_types_tests.go @@ -33,7 +33,7 @@ type TestCase struct { ErrorMessage string } -func generateValidationTypesTests() { +func generateValidationTypesEndToEndTests() { generateValidationTypesTestsFile("no_pointer_tests.tpl", "generated_endtoend_no_pointer_tests.go", false) generateValidationTypesTestsFile("pointer_tests.tpl", "generated_endtoend_pointer_tests.go", true) } @@ -100,7 +100,7 @@ func generateValidationTypesTestsFile(tpl, dest string, pointer bool) { log.Printf("Generating %s done\n", dest) } -func (at *AllTestCasesToGenerate) GenerateFile(tplFile, output string) error { +func (tc *AllTestCasesToGenerate) GenerateFile(tplFile, output string) error { tpl, err := os.ReadFile(tplFile) if err != nil { return fmt.Errorf("error reading %s: %s", tplFile, err) @@ -112,7 +112,7 @@ func (at *AllTestCasesToGenerate) GenerateFile(tplFile, output string) error { } code := new(bytes.Buffer) - if err := tmpl.Execute(code, at); err != nil { + if err := tmpl.Execute(code, tc); err != nil { return err } From 64050faec10930da585103e794407993ae35fa2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Mon, 27 Oct 2025 15:30:55 -0300 Subject: [PATCH 10/31] doc: initial testgen readme --- testgen/README.md | 119 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 testgen/README.md diff --git a/testgen/README.md b/testgen/README.md new file mode 100644 index 0000000..b101ed1 --- /dev/null +++ b/testgen/README.md @@ -0,0 +1,119 @@ +# TestGen + +TestGen is the tool responsible for generating tests related to ValidGen validators and supported types. +These generated tests included unit tests, end-to-end tests, and benchmark tests. +In the case of benchmark tests, it means comparing ValidGen and GoValidator. + +## Why a new tool? + +First of all, it is necessary to answer the question: why a new tool to generate tests? + +Currently, ValidGen has 21 possible validations with support for some types: + +| Validation | Basic types | Slice | Array | Map | +| - | - | - | - | - | +| eq | STRING INT FLOAT BOOL | | | | +| required | STRING INT FLOAT BOOL | STRING INT FLOAT BOOL | | STRING INT FLOAT BOOL | +| gt | INT FLOAT | | | | +| gte | INT FLOAT | | | | +| lte | INT FLOAT | | | | +| lt | INT FLOAT | | | | +| min | STRING | STRING INT FLOAT BOOL | | STRING INT FLOAT BOOL | +| max | STRING | STRING INT FLOAT BOOL | | STRING INT FLOAT BOOL | +| eq_ignore_case | STRING | | | | +| len | STRING | STRING INT FLOAT BOOL | | STRING INT FLOAT BOOL | +| neq | STRING INT FLOAT BOOL | | | | +| neq_ignore_case | STRING | | | | +| in | STRING INT FLOAT BOOL | STRING INT FLOAT BOOL | STRING INT FLOAT BOOL | STRING INT FLOAT BOOL | +| nin | STRING INT FLOAT BOOL | STRING INT FLOAT BOOL | STRING INT FLOAT BOOL | STRING INT FLOAT BOOL | +| email | STRING | | | | +| eqfield | STRING INT BOOL | | | | +| neqfield | STRING INT BOOL | | | | +| gtefield | INT | | | | +| gtfield | INT | | | | +| ltefield | INT | | | | +| ltfield | INT | | | | + +In this table, STRING represents the string Go type, and BOOL represents the bool Go type. +But INT represents the ten integer Go types: int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64. +In the same way, FLOAT represents the 2 float go types: float32, float64. +In the same way, slice STRING is just []string, but slice INT is split between all integer Go types. +For array and map, the rule is the same. +And, an important modifier is "*" (pointer) because the code generated is different with or without a pointer. + +For each possible combination (validation x type) is necessary to have the following tests: +- Unit test in the analyzer phase +- Unit test in the code generator phase +- Benchmark test between ValidGen and GoValidator +- End-to-end test + +As it is necessary to test all valid and invalid scenarios, it is necessary to test all validations against all types. +At this time, it means: +- Go types (14) +- Validations (21) +- Test types (4) +- Types with and without a pointer (2) +- Tests with valid and invalid inputs (2) + +14 x 21 x 4 x 2 x 2 = 4.704 distinct test cases :-) + +With all the tests that need to be created (valid inputs, invalid inputs) for unit tests, benchmark, and end-to-end tests, creating the tests "by hand" is a tedious and error-prone task. + +Some of these necessary unit tests were created "by hand", but it is a pain to keep the code in sync when supporting new operations and types. + +At this time, ValidGen already has two generators: +- To generate benchmark tests between ValidGen and GoValidator +- To generate end-to-end tests + - to validate ValidGen with integer types + - to validate ValidGen with float types + - to validate all possible use cases in ValidGen (all validations x all types) + +But these generators do not have a common configuration, do not implement all tests for all cases, and keeping the distinct configuration files in sync is painful. + +Beyond that, some new generators could be created: +- Unit tests to validate operations +- Unit tests to validate operation x type +- Unit tests to validate the "buildValidationCode" function +- Unit tests to validate the "condition table" +- Parser tests +- Almost all existing end-to-end tests could be generated +- Examples (in _examples/) could be generated + +And, for all cases, valid scenarios and invalid scenarios must be generated. + +## What TestGen does + +TestGen generates the following tests: +- Benchmark tests between ValidGen and GoValidator +- End-to-end tests with all possible use cases (all validations vs all types vs valid and invalid inputs) +- Unit tests to validate operations +- Unit tests to validate operation vs type +- Unit tests to validate the "buildValidationCode" function +- Unit tests to validate "condition table" result +- Parser tests (parser_tests.go) +- Examples (in _examples/) + +In some cases, valid scenarios and invalid scenarios must be generated. + +## How TestGen works + +To be possible to generate all these tests, TestGen must have a configuration with: +- All valid operations +- All valid go types +- All valid operation x type +- Valid input cases for each operation x type +- Invalid input cases for each operation x type +- Equivalent GoValidator tag + +## Steps to generate the tests + +The steps to generate the tests are: + +```bash +# Enter in the project root folder +cd validgen + +# Run testgen +make testgen +``` + From 2ee054c9ed6b31f0d2d55714a17c6636717f21db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Mon, 27 Oct 2025 15:38:57 -0300 Subject: [PATCH 11/31] chore: remove useless code --- testgen/generate_validation_types_tests.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/testgen/generate_validation_types_tests.go b/testgen/generate_validation_types_tests.go index 3984617..f848725 100644 --- a/testgen/generate_validation_types_tests.go +++ b/testgen/generate_validation_types_tests.go @@ -116,10 +116,6 @@ func (tc *AllTestCasesToGenerate) GenerateFile(tplFile, output string) error { return err } - // if err := os.WriteFile(output, code.Bytes(), 0644); err != nil { - // return err - // } - formattedCode, err := format.Source(code.Bytes()) if err != nil { return err From abc9fe58b5fa58c76a825b7e498658d3db137588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Mon, 27 Oct 2025 16:10:40 -0300 Subject: [PATCH 12/31] feat: testgen generating tests to check function validate output --- Makefile | 2 +- testgen/function_code_test.tpl | 69 +++++++++++ testgen/generate_function_code_tests.go | 156 ++++++++++++++++++++++++ testgen/generate_tests.go | 5 +- 4 files changed, 229 insertions(+), 3 deletions(-) create mode 100644 testgen/function_code_test.tpl create mode 100644 testgen/generate_function_code_tests.go diff --git a/Makefile b/Makefile index c85b537..05dcfc0 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ build: clean testgen: @echo "Generating tests" - cd testgen/; rm -f generated_*.go; go run *.go; mv generated_endtoend_*tests.go ../tests/endtoend/; mv generated_validation_*_test.go ../internal/codegenerator/ + cd testgen/; rm -f generated_*.go; go run *.go && mv generated_endtoend_*tests.go ../tests/endtoend/ && mv generated_validation_*_test.go ../internal/codegenerator/ && mv generated_function_code_*_test.go ../internal/codegenerator/ endtoendtests: build @echo "Running endtoend tests" diff --git a/testgen/function_code_test.tpl b/testgen/function_code_test.tpl new file mode 100644 index 0000000..aaba70b --- /dev/null +++ b/testgen/function_code_test.tpl @@ -0,0 +1,69 @@ +// Code generated by TestGen. DO NOT EDIT. + +package codegenerator + +import ( + "testing" + + "github.com/opencodeco/validgen/internal/analyzer" + "github.com/opencodeco/validgen/internal/common" + "github.com/opencodeco/validgen/internal/parser" + "github.com/sergi/go-diff/diffmatchpatch" +) + +func {{.FuncName}}(t *testing.T) { + tests := []struct { + name string + structInfo *analyzer.Struct + want string + }{ +{{range .Tests}} { + name: "{{.TestName}}", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "{{.StructName}}", + Fields: []parser.Field{ + {{range .Fields}} + { + FieldName: "{{.Name}}", + Type: common.FieldType{ComposedType: "{{.Type.ComposedType}}", BaseType: "{{.Type.BaseType}}", Size: "{{.Type.Size}}"}, + Tag: `validate:"{{.Tag}}"`, + }, + {{end}} + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + {{range .Fields}} + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `{{.Tag}}`)}, + }, + {{end}} + }, + }, + want: `{{.ExpectedCode}}`, + }, +{{end}} + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gv := GenValidations{ + Struct: tt.structInfo, + } + got, err := gv.BuildFuncValidatorCode() + if err != nil { + t.Errorf("FileValidator.GenerateValidator() error = %v, wantErr %v", err, nil) + return + } + if got != tt.want { + t.Errorf("FileValidator.GenerateValidator() = %v, want %v", got, tt.want) + dmp := diffmatchpatch.New() + diffs := dmp.DiffMain(tt.want, got, false) + if len(diffs) > 1 { + t.Errorf("FileValidator.GenerateValidator() diff = \n%v", dmp.DiffPrettyText(diffs)) + } + } + }) + } +} diff --git a/testgen/generate_function_code_tests.go b/testgen/generate_function_code_tests.go new file mode 100644 index 0000000..d7c45f6 --- /dev/null +++ b/testgen/generate_function_code_tests.go @@ -0,0 +1,156 @@ +package main + +import ( + "bytes" + "fmt" + "go/format" + "log" + "os" + "text/template" + + "github.com/opencodeco/validgen/internal/analyzer" + "github.com/opencodeco/validgen/internal/codegenerator" + "github.com/opencodeco/validgen/internal/common" + "github.com/opencodeco/validgen/internal/parser" + "golang.org/x/text/cases" + "golang.org/x/text/language" +) + +type FunctionCodeTestCases struct { + FuncName string + Tests []FunctionCodeTestCase +} + +type FunctionCodeTestCase struct { + TestName string + StructName string + Fields []FunctionCodeTestField + ExpectedCode string +} + +type FunctionCodeTestField struct { + Name string + Type common.FieldType + Tag string +} + +func generateFunctionCodeUnitTests() { + generateFunctionCodeTestsFile("function_code_test.tpl", "generated_function_code_no_pointer_test.go", false) + generateFunctionCodeTestsFile("function_code_test.tpl", "generated_function_code_pointer_test.go", true) +} + +func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { + log.Printf("Generating function code test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) + + funcName := "TestBuildFunctionCode" + if pointer { + funcName += "Pointer" + } + + testCases := FunctionCodeTestCases{ + FuncName: funcName, + } + + for _, typeValidation := range typesValidation { + testCases.Tests = append(testCases.Tests, FunctionCodeTestCase{ + TestName: typeValidation.tag + "Struct", + StructName: typeValidation.tag + "Struct", + }) + currentTest := &testCases.Tests[len(testCases.Tests)-1] + structInfo := &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: currentTest.StructName, + }, + } + + for _, toGenerate := range typeValidation.testCases { + // Default ("") gen no pointer and pointer test. + if toGenerate.generateFor != "" { + if toGenerate.generateFor == "pointer" && !pointer { + continue + } + if toGenerate.generateFor == "nopointer" && pointer { + continue + } + } + + normalizedType := toGenerate.typeClass + if pointer { + normalizedType = "*" + normalizedType + } + + fieldTypes, _ := common.HelperFromNormalizedToFieldTypes(normalizedType) + for _, fieldType := range fieldTypes { + validation := typeValidation.tag + if typeValidation.argsCount != common.ZeroValue { + validation += "=" + toGenerate.validation + } + fieldName := "Field" + cases.Title(language.Und).String(typeValidation.tag) + fieldType.ToStringName() + parsedValidation, err := analyzer.ParserValidation(validation) + if err != nil { + log.Fatalf("failed to parse validation %q: %v", validation, err) + } + + currentTest.Fields = append(currentTest.Fields, FunctionCodeTestField{ + Name: fieldName, + Type: fieldType, + Tag: validation, + }) + + structInfo.Fields = append(structInfo.Fields, parser.Field{ + FieldName: fieldName, + Type: fieldType, + Tag: `validate:"` + validation + `"`, + }) + structInfo.FieldsValidations = append(structInfo.FieldsValidations, analyzer.FieldValidations{ + Validations: []*analyzer.Validation{parsedValidation}, + }) + } + + gv := codegenerator.GenValidations{ + Struct: structInfo, + } + + got, err := gv.BuildFuncValidatorCode() + if err != nil { + log.Fatalf("failed to build function validator code for struct %q: %v", currentTest.StructName, err) + } + currentTest.ExpectedCode = got + } + } + + if err := testCases.GenerateFile(tpl, dest); err != nil { + log.Fatalf("error generating function code tests file %s", err) + } + + log.Printf("Generating %s done\n", dest) +} + +func (tc *FunctionCodeTestCases) GenerateFile(tplFile, output string) error { + tpl, err := os.ReadFile(tplFile) + if err != nil { + return fmt.Errorf("error reading %s: %s", tplFile, err) + } + + tmpl, err := template.New("ValidationCodeTests").Parse(string(tpl)) + if err != nil { + return err + } + + code := new(bytes.Buffer) + if err := tmpl.Execute(code, tc); err != nil { + return err + } + + formattedCode, err := format.Source(code.Bytes()) + if err != nil { + return err + } + + if err := os.WriteFile(output, formattedCode, 0644); err != nil { + return err + } + + return nil +} diff --git a/testgen/generate_tests.go b/testgen/generate_tests.go index 3a2775a..1b06a69 100644 --- a/testgen/generate_tests.go +++ b/testgen/generate_tests.go @@ -7,8 +7,9 @@ import ( func main() { fmt.Println("Generating tests files") - generateValidationTypesTests() - generateValidationCodeTests() + generateValidationTypesEndToEndTests() + generateValidationCodeUnitTests() + generateFunctionCodeUnitTests() fmt.Println("Generating done") } From f06c1cb014ff0f1dc31c5e3ca623e3808ec0b658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Mon, 27 Oct 2025 16:12:19 -0300 Subject: [PATCH 13/31] test: commit tests generated by testgen --- ...generated_function_code_no_pointer_test.go | 4472 ++++++++++++++++ .../generated_function_code_pointer_test.go | 4654 +++++++++++++++++ 2 files changed, 9126 insertions(+) create mode 100644 internal/codegenerator/generated_function_code_no_pointer_test.go create mode 100644 internal/codegenerator/generated_function_code_pointer_test.go diff --git a/internal/codegenerator/generated_function_code_no_pointer_test.go b/internal/codegenerator/generated_function_code_no_pointer_test.go new file mode 100644 index 0000000..2cd601d --- /dev/null +++ b/internal/codegenerator/generated_function_code_no_pointer_test.go @@ -0,0 +1,4472 @@ +// Code generated by TestGen. DO NOT EDIT. + +package codegenerator + +import ( + "testing" + + "github.com/opencodeco/validgen/internal/analyzer" + "github.com/opencodeco/validgen/internal/common" + "github.com/opencodeco/validgen/internal/parser" + "github.com/sergi/go-diff/diffmatchpatch" +) + +func TestBuildFunctionCode(t *testing.T) { + tests := []struct { + name string + structInfo *analyzer.Struct + want string + }{ + { + name: "emailStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "emailStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldEmailString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"email"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `email`)}, + }, + }, + }, + want: `func emailStructValidate(obj *emailStruct) []error { +var errs []error +if !(types.IsValidEmail(obj.FieldEmailString)) { +errs = append(errs, types.NewValidationError("FieldEmailString must be a valid email")) +} +return errs +} +`, + }, + { + name: "requiredStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "requiredStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldRequiredString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt", + Type: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt8", + Type: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt16", + Type: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt32", + Type: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt64", + Type: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint", + Type: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint8", + Type: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint16", + Type: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint32", + Type: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint64", + Type: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat32", + Type: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat64", + Type: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredBool", + Type: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredStringSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredIntSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUintSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredBoolSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredStringMap", + Type: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredIntMap", + Type: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUintMap", + Type: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredBoolMap", + Type: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + Tag: `validate:"required"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + }, + }, + want: `func requiredStructValidate(obj *requiredStruct) []error { +var errs []error +if !(obj.FieldRequiredString != "") { +errs = append(errs, types.NewValidationError("FieldRequiredString is required")) +} +if !(obj.FieldRequiredInt != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt is required")) +} +if !(obj.FieldRequiredInt8 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8 is required")) +} +if !(obj.FieldRequiredInt16 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16 is required")) +} +if !(obj.FieldRequiredInt32 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32 is required")) +} +if !(obj.FieldRequiredInt64 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64 is required")) +} +if !(obj.FieldRequiredUint != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint is required")) +} +if !(obj.FieldRequiredUint8 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8 is required")) +} +if !(obj.FieldRequiredUint16 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16 is required")) +} +if !(obj.FieldRequiredUint32 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32 is required")) +} +if !(obj.FieldRequiredUint64 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64 is required")) +} +if !(obj.FieldRequiredFloat32 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32 is required")) +} +if !(obj.FieldRequiredFloat64 != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64 is required")) +} +if !(obj.FieldRequiredBool != false) { +errs = append(errs, types.NewValidationError("FieldRequiredBool is required")) +} +if !(len(obj.FieldRequiredStringSlice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredStringSlice must not be empty")) +} +if !(len(obj.FieldRequiredIntSlice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntSlice must not be empty")) +} +if !(len(obj.FieldRequiredInt8Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8Slice must not be empty")) +} +if !(len(obj.FieldRequiredInt16Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16Slice must not be empty")) +} +if !(len(obj.FieldRequiredInt32Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32Slice must not be empty")) +} +if !(len(obj.FieldRequiredInt64Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64Slice must not be empty")) +} +if !(len(obj.FieldRequiredUintSlice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintSlice must not be empty")) +} +if !(len(obj.FieldRequiredUint8Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8Slice must not be empty")) +} +if !(len(obj.FieldRequiredUint16Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16Slice must not be empty")) +} +if !(len(obj.FieldRequiredUint32Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32Slice must not be empty")) +} +if !(len(obj.FieldRequiredUint64Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64Slice must not be empty")) +} +if !(len(obj.FieldRequiredFloat32Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32Slice must not be empty")) +} +if !(len(obj.FieldRequiredFloat64Slice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64Slice must not be empty")) +} +if !(len(obj.FieldRequiredBoolSlice) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolSlice must not be empty")) +} +if !(len(obj.FieldRequiredStringMap) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredStringMap must not be empty")) +} +if !(len(obj.FieldRequiredIntMap) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntMap must not be empty")) +} +if !(len(obj.FieldRequiredInt8Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8Map must not be empty")) +} +if !(len(obj.FieldRequiredInt16Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16Map must not be empty")) +} +if !(len(obj.FieldRequiredInt32Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32Map must not be empty")) +} +if !(len(obj.FieldRequiredInt64Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64Map must not be empty")) +} +if !(len(obj.FieldRequiredUintMap) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintMap must not be empty")) +} +if !(len(obj.FieldRequiredUint8Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8Map must not be empty")) +} +if !(len(obj.FieldRequiredUint16Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16Map must not be empty")) +} +if !(len(obj.FieldRequiredUint32Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32Map must not be empty")) +} +if !(len(obj.FieldRequiredUint64Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64Map must not be empty")) +} +if !(len(obj.FieldRequiredFloat32Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32Map must not be empty")) +} +if !(len(obj.FieldRequiredFloat64Map) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64Map must not be empty")) +} +if !(len(obj.FieldRequiredBoolMap) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolMap must not be empty")) +} +return errs +} +`, + }, + { + name: "eqStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "eqStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldEqString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"eq=abcde"`, + }, + + { + FieldName: "FieldEqInt", + Type: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqInt8", + Type: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqInt16", + Type: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqInt32", + Type: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqInt64", + Type: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUint", + Type: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUint8", + Type: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUint16", + Type: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUint32", + Type: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUint64", + Type: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqFloat32", + Type: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + Tag: `validate:"eq=12.34"`, + }, + + { + FieldName: "FieldEqFloat64", + Type: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + Tag: `validate:"eq=12.34"`, + }, + + { + FieldName: "FieldEqBool", + Type: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + Tag: `validate:"eq=true"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=abcde`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=true`)}, + }, + }, + }, + want: `func eqStructValidate(obj *eqStruct) []error { +var errs []error +if !(obj.FieldEqString == "abcde") { +errs = append(errs, types.NewValidationError("FieldEqString must be equal to 'abcde'")) +} +if !(obj.FieldEqInt == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt must be equal to 32")) +} +if !(obj.FieldEqInt8 == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt8 must be equal to 32")) +} +if !(obj.FieldEqInt16 == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt16 must be equal to 32")) +} +if !(obj.FieldEqInt32 == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt32 must be equal to 32")) +} +if !(obj.FieldEqInt64 == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt64 must be equal to 32")) +} +if !(obj.FieldEqUint == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint must be equal to 32")) +} +if !(obj.FieldEqUint8 == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint8 must be equal to 32")) +} +if !(obj.FieldEqUint16 == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint16 must be equal to 32")) +} +if !(obj.FieldEqUint32 == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint32 must be equal to 32")) +} +if !(obj.FieldEqUint64 == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint64 must be equal to 32")) +} +if !(obj.FieldEqFloat32 == 12.34) { +errs = append(errs, types.NewValidationError("FieldEqFloat32 must be equal to 12.34")) +} +if !(obj.FieldEqFloat64 == 12.34) { +errs = append(errs, types.NewValidationError("FieldEqFloat64 must be equal to 12.34")) +} +if !(obj.FieldEqBool == true) { +errs = append(errs, types.NewValidationError("FieldEqBool must be equal to true")) +} +return errs +} +`, + }, + { + name: "neqStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "neqStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldNeqString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"neq=abcde"`, + }, + + { + FieldName: "FieldNeqInt", + Type: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqInt8", + Type: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqInt16", + Type: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqInt32", + Type: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqInt64", + Type: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUint", + Type: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUint8", + Type: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUint16", + Type: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUint32", + Type: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUint64", + Type: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqFloat32", + Type: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + Tag: `validate:"neq=12.34"`, + }, + + { + FieldName: "FieldNeqFloat64", + Type: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + Tag: `validate:"neq=12.34"`, + }, + + { + FieldName: "FieldNeqBool", + Type: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + Tag: `validate:"neq=true"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=abcde`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=true`)}, + }, + }, + }, + want: `func neqStructValidate(obj *neqStruct) []error { +var errs []error +if !(obj.FieldNeqString != "abcde") { +errs = append(errs, types.NewValidationError("FieldNeqString must not be equal to 'abcde'")) +} +if !(obj.FieldNeqInt != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt must not be equal to 32")) +} +if !(obj.FieldNeqInt8 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt8 must not be equal to 32")) +} +if !(obj.FieldNeqInt16 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt16 must not be equal to 32")) +} +if !(obj.FieldNeqInt32 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt32 must not be equal to 32")) +} +if !(obj.FieldNeqInt64 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt64 must not be equal to 32")) +} +if !(obj.FieldNeqUint != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint must not be equal to 32")) +} +if !(obj.FieldNeqUint8 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint8 must not be equal to 32")) +} +if !(obj.FieldNeqUint16 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint16 must not be equal to 32")) +} +if !(obj.FieldNeqUint32 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint32 must not be equal to 32")) +} +if !(obj.FieldNeqUint64 != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint64 must not be equal to 32")) +} +if !(obj.FieldNeqFloat32 != 12.34) { +errs = append(errs, types.NewValidationError("FieldNeqFloat32 must not be equal to 12.34")) +} +if !(obj.FieldNeqFloat64 != 12.34) { +errs = append(errs, types.NewValidationError("FieldNeqFloat64 must not be equal to 12.34")) +} +if !(obj.FieldNeqBool != true) { +errs = append(errs, types.NewValidationError("FieldNeqBool must not be equal to true")) +} +return errs +} +`, + }, + { + name: "gtStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "gtStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldGtInt", + Type: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtInt8", + Type: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtInt16", + Type: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtInt32", + Type: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtInt64", + Type: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUint", + Type: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUint8", + Type: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUint16", + Type: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUint32", + Type: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUint64", + Type: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtFloat32", + Type: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + Tag: `validate:"gt=12.34"`, + }, + + { + FieldName: "FieldGtFloat64", + Type: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + Tag: `validate:"gt=12.34"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=12.34`)}, + }, + }, + }, + want: `func gtStructValidate(obj *gtStruct) []error { +var errs []error +if !(obj.FieldGtInt > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt must be > 32")) +} +if !(obj.FieldGtInt8 > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt8 must be > 32")) +} +if !(obj.FieldGtInt16 > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt16 must be > 32")) +} +if !(obj.FieldGtInt32 > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt32 must be > 32")) +} +if !(obj.FieldGtInt64 > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt64 must be > 32")) +} +if !(obj.FieldGtUint > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint must be > 32")) +} +if !(obj.FieldGtUint8 > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint8 must be > 32")) +} +if !(obj.FieldGtUint16 > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint16 must be > 32")) +} +if !(obj.FieldGtUint32 > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint32 must be > 32")) +} +if !(obj.FieldGtUint64 > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint64 must be > 32")) +} +if !(obj.FieldGtFloat32 > 12.34) { +errs = append(errs, types.NewValidationError("FieldGtFloat32 must be > 12.34")) +} +if !(obj.FieldGtFloat64 > 12.34) { +errs = append(errs, types.NewValidationError("FieldGtFloat64 must be > 12.34")) +} +return errs +} +`, + }, + { + name: "gteStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "gteStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldGteInt", + Type: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteInt8", + Type: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteInt16", + Type: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteInt32", + Type: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteInt64", + Type: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUint", + Type: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUint8", + Type: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUint16", + Type: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUint32", + Type: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUint64", + Type: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteFloat32", + Type: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + Tag: `validate:"gte=12.34"`, + }, + + { + FieldName: "FieldGteFloat64", + Type: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + Tag: `validate:"gte=12.34"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=12.34`)}, + }, + }, + }, + want: `func gteStructValidate(obj *gteStruct) []error { +var errs []error +if !(obj.FieldGteInt >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt must be >= 32")) +} +if !(obj.FieldGteInt8 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt8 must be >= 32")) +} +if !(obj.FieldGteInt16 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt16 must be >= 32")) +} +if !(obj.FieldGteInt32 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt32 must be >= 32")) +} +if !(obj.FieldGteInt64 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt64 must be >= 32")) +} +if !(obj.FieldGteUint >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint must be >= 32")) +} +if !(obj.FieldGteUint8 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint8 must be >= 32")) +} +if !(obj.FieldGteUint16 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint16 must be >= 32")) +} +if !(obj.FieldGteUint32 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint32 must be >= 32")) +} +if !(obj.FieldGteUint64 >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint64 must be >= 32")) +} +if !(obj.FieldGteFloat32 >= 12.34) { +errs = append(errs, types.NewValidationError("FieldGteFloat32 must be >= 12.34")) +} +if !(obj.FieldGteFloat64 >= 12.34) { +errs = append(errs, types.NewValidationError("FieldGteFloat64 must be >= 12.34")) +} +return errs +} +`, + }, + { + name: "ltStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "ltStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldLtInt", + Type: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtInt8", + Type: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtInt16", + Type: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtInt32", + Type: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtInt64", + Type: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUint", + Type: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUint8", + Type: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUint16", + Type: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUint32", + Type: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUint64", + Type: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtFloat32", + Type: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + Tag: `validate:"lt=12.34"`, + }, + + { + FieldName: "FieldLtFloat64", + Type: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + Tag: `validate:"lt=12.34"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=12.34`)}, + }, + }, + }, + want: `func ltStructValidate(obj *ltStruct) []error { +var errs []error +if !(obj.FieldLtInt < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt must be < 32")) +} +if !(obj.FieldLtInt8 < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt8 must be < 32")) +} +if !(obj.FieldLtInt16 < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt16 must be < 32")) +} +if !(obj.FieldLtInt32 < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt32 must be < 32")) +} +if !(obj.FieldLtInt64 < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt64 must be < 32")) +} +if !(obj.FieldLtUint < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint must be < 32")) +} +if !(obj.FieldLtUint8 < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint8 must be < 32")) +} +if !(obj.FieldLtUint16 < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint16 must be < 32")) +} +if !(obj.FieldLtUint32 < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint32 must be < 32")) +} +if !(obj.FieldLtUint64 < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint64 must be < 32")) +} +if !(obj.FieldLtFloat32 < 12.34) { +errs = append(errs, types.NewValidationError("FieldLtFloat32 must be < 12.34")) +} +if !(obj.FieldLtFloat64 < 12.34) { +errs = append(errs, types.NewValidationError("FieldLtFloat64 must be < 12.34")) +} +return errs +} +`, + }, + { + name: "lteStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "lteStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldLteInt", + Type: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteInt8", + Type: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteInt16", + Type: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteInt32", + Type: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteInt64", + Type: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUint", + Type: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUint8", + Type: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUint16", + Type: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUint32", + Type: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUint64", + Type: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteFloat32", + Type: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + Tag: `validate:"lte=12.34"`, + }, + + { + FieldName: "FieldLteFloat64", + Type: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + Tag: `validate:"lte=12.34"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=12.34`)}, + }, + }, + }, + want: `func lteStructValidate(obj *lteStruct) []error { +var errs []error +if !(obj.FieldLteInt <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt must be <= 32")) +} +if !(obj.FieldLteInt8 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt8 must be <= 32")) +} +if !(obj.FieldLteInt16 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt16 must be <= 32")) +} +if !(obj.FieldLteInt32 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt32 must be <= 32")) +} +if !(obj.FieldLteInt64 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt64 must be <= 32")) +} +if !(obj.FieldLteUint <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint must be <= 32")) +} +if !(obj.FieldLteUint8 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint8 must be <= 32")) +} +if !(obj.FieldLteUint16 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint16 must be <= 32")) +} +if !(obj.FieldLteUint32 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint32 must be <= 32")) +} +if !(obj.FieldLteUint64 <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint64 must be <= 32")) +} +if !(obj.FieldLteFloat32 <= 12.34) { +errs = append(errs, types.NewValidationError("FieldLteFloat32 must be <= 12.34")) +} +if !(obj.FieldLteFloat64 <= 12.34) { +errs = append(errs, types.NewValidationError("FieldLteFloat64 must be <= 12.34")) +} +return errs +} +`, + }, + { + name: "minStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "minStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldMinString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"min=5"`, + }, + + { + FieldName: "FieldMinStringSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinIntSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUintSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinFloat32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinFloat64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinBoolSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinStringMap", + Type: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinIntMap", + Type: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUintMap", + Type: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinFloat32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinFloat64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinBoolMap", + Type: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + Tag: `validate:"min=2"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=5`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + }, + }, + want: `func minStructValidate(obj *minStruct) []error { +var errs []error +if !(len(obj.FieldMinString) >= 5) { +errs = append(errs, types.NewValidationError("FieldMinString length must be >= 5")) +} +if !(len(obj.FieldMinStringSlice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinStringSlice must have at least 2 elements")) +} +if !(len(obj.FieldMinIntSlice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinIntSlice must have at least 2 elements")) +} +if !(len(obj.FieldMinInt8Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt8Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinInt16Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt16Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinInt32Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt32Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinInt64Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt64Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinUintSlice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUintSlice must have at least 2 elements")) +} +if !(len(obj.FieldMinUint8Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint8Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinUint16Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint16Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinUint32Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint32Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinUint64Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint64Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinFloat32Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat32Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinFloat64Slice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat64Slice must have at least 2 elements")) +} +if !(len(obj.FieldMinBoolSlice) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinBoolSlice must have at least 2 elements")) +} +if !(len(obj.FieldMinStringMap) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinStringMap must have at least 2 elements")) +} +if !(len(obj.FieldMinIntMap) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinIntMap must have at least 2 elements")) +} +if !(len(obj.FieldMinInt8Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt8Map must have at least 2 elements")) +} +if !(len(obj.FieldMinInt16Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt16Map must have at least 2 elements")) +} +if !(len(obj.FieldMinInt32Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt32Map must have at least 2 elements")) +} +if !(len(obj.FieldMinInt64Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt64Map must have at least 2 elements")) +} +if !(len(obj.FieldMinUintMap) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUintMap must have at least 2 elements")) +} +if !(len(obj.FieldMinUint8Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint8Map must have at least 2 elements")) +} +if !(len(obj.FieldMinUint16Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint16Map must have at least 2 elements")) +} +if !(len(obj.FieldMinUint32Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint32Map must have at least 2 elements")) +} +if !(len(obj.FieldMinUint64Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint64Map must have at least 2 elements")) +} +if !(len(obj.FieldMinFloat32Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat32Map must have at least 2 elements")) +} +if !(len(obj.FieldMinFloat64Map) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat64Map must have at least 2 elements")) +} +if !(len(obj.FieldMinBoolMap) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinBoolMap must have at least 2 elements")) +} +return errs +} +`, + }, + { + name: "maxStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "maxStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldMaxString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"max=3"`, + }, + + { + FieldName: "FieldMaxStringSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxIntSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUintSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxFloat32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxFloat64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxBoolSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxStringMap", + Type: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxIntMap", + Type: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUintMap", + Type: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxFloat32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxFloat64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxBoolMap", + Type: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + Tag: `validate:"max=1"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=1`)}, + }, + }, + }, + want: `func maxStructValidate(obj *maxStruct) []error { +var errs []error +if !(len(obj.FieldMaxString) <= 3) { +errs = append(errs, types.NewValidationError("FieldMaxString length must be <= 3")) +} +if !(len(obj.FieldMaxStringSlice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxStringSlice must have at most 2 elements")) +} +if !(len(obj.FieldMaxIntSlice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxIntSlice must have at most 2 elements")) +} +if !(len(obj.FieldMaxInt8Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt8Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxInt16Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt16Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxInt32Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt32Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxInt64Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt64Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxUintSlice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUintSlice must have at most 2 elements")) +} +if !(len(obj.FieldMaxUint8Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint8Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxUint16Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint16Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxUint32Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint32Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxUint64Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint64Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxFloat32Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat32Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxFloat64Slice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat64Slice must have at most 2 elements")) +} +if !(len(obj.FieldMaxBoolSlice) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxBoolSlice must have at most 2 elements")) +} +if !(len(obj.FieldMaxStringMap) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxStringMap must have at most 2 elements")) +} +if !(len(obj.FieldMaxIntMap) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxIntMap must have at most 2 elements")) +} +if !(len(obj.FieldMaxInt8Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt8Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxInt16Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt16Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxInt32Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt32Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxInt64Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt64Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxUintMap) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUintMap must have at most 2 elements")) +} +if !(len(obj.FieldMaxUint8Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint8Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxUint16Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint16Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxUint32Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint32Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxUint64Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint64Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxFloat32Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat32Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxFloat64Map) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat64Map must have at most 2 elements")) +} +if !(len(obj.FieldMaxBoolMap) <= 1) { +errs = append(errs, types.NewValidationError("FieldMaxBoolMap must have at most 1 elements")) +} +return errs +} +`, + }, + { + name: "eq_ignore_caseStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "eq_ignore_caseStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldEq_ignore_caseString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"eq_ignore_case=abcde"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq_ignore_case=abcde`)}, + }, + }, + }, + want: `func eq_ignore_caseStructValidate(obj *eq_ignore_caseStruct) []error { +var errs []error +if !(types.EqualFold(obj.FieldEq_ignore_caseString, "abcde")) { +errs = append(errs, types.NewValidationError("FieldEq_ignore_caseString must be equal to 'abcde'")) +} +return errs +} +`, + }, + { + name: "neq_ignore_caseStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "neq_ignore_caseStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldNeq_ignore_caseString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"neq_ignore_case=abcde"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq_ignore_case=abcde`)}, + }, + }, + }, + want: `func neq_ignore_caseStructValidate(obj *neq_ignore_caseStruct) []error { +var errs []error +if !(!types.EqualFold(obj.FieldNeq_ignore_caseString, "abcde")) { +errs = append(errs, types.NewValidationError("FieldNeq_ignore_caseString must not be equal to 'abcde'")) +} +return errs +} +`, + }, + { + name: "lenStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "lenStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldLenString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenStringSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenIntSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUintSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenFloat32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenFloat64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenBoolSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenStringMap", + Type: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenIntMap", + Type: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUintMap", + Type: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenFloat32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenFloat64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenBoolMap", + Type: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + Tag: `validate:"len=2"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + }, + }, + want: `func lenStructValidate(obj *lenStruct) []error { +var errs []error +if !(len(obj.FieldLenString) == 2) { +errs = append(errs, types.NewValidationError("FieldLenString length must be 2")) +} +if !(len(obj.FieldLenStringSlice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringSlice must have exactly 2 elements")) +} +if !(len(obj.FieldLenIntSlice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenIntSlice must have exactly 2 elements")) +} +if !(len(obj.FieldLenInt8Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt8Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenInt16Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt16Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenInt32Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt32Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenInt64Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt64Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenUintSlice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUintSlice must have exactly 2 elements")) +} +if !(len(obj.FieldLenUint8Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint8Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenUint16Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint16Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenUint32Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint32Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenUint64Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint64Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenFloat32Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat32Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenFloat64Slice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat64Slice must have exactly 2 elements")) +} +if !(len(obj.FieldLenBoolSlice) == 2) { +errs = append(errs, types.NewValidationError("FieldLenBoolSlice must have exactly 2 elements")) +} +if !(len(obj.FieldLenStringMap) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringMap must have exactly 2 elements")) +} +if !(len(obj.FieldLenIntMap) == 2) { +errs = append(errs, types.NewValidationError("FieldLenIntMap must have exactly 2 elements")) +} +if !(len(obj.FieldLenInt8Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt8Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenInt16Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt16Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenInt32Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt32Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenInt64Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt64Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenUintMap) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUintMap must have exactly 2 elements")) +} +if !(len(obj.FieldLenUint8Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint8Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenUint16Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint16Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenUint32Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint32Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenUint64Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint64Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenFloat32Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat32Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenFloat64Map) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat64Map must have exactly 2 elements")) +} +if !(len(obj.FieldLenBoolMap) == 2) { +errs = append(errs, types.NewValidationError("FieldLenBoolMap must have exactly 2 elements")) +} +return errs +} +`, + }, + { + name: "inStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "inStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldInString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"in=ab cd ef"`, + }, + + { + FieldName: "FieldInInt", + Type: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt8", + Type: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt16", + Type: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt32", + Type: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt64", + Type: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint", + Type: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint8", + Type: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint16", + Type: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint32", + Type: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint64", + Type: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInFloat32", + Type: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInFloat64", + Type: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInBool", + Type: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + Tag: `validate:"in=true"`, + }, + + { + FieldName: "FieldInStringSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + Tag: `validate:"in=ab cd ef"`, + }, + + { + FieldName: "FieldInIntSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUintSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInFloat32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInFloat64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInBoolSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + Tag: `validate:"in=true"`, + }, + + { + FieldName: "FieldInStringArray", + Type: common.FieldType{ComposedType: "[N]", BaseType: "string", Size: "3"}, + Tag: `validate:"in=ab cd ef"`, + }, + + { + FieldName: "FieldInIntArray", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt8Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int8", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt16Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int16", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt32Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int32", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt64Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int64", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUintArray", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint8Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint8", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint16Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint16", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint32Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint32", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint64Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint64", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInFloat32Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "float32", Size: "3"}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInFloat64Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "float64", Size: "3"}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInBoolArray", + Type: common.FieldType{ComposedType: "[N]", BaseType: "bool", Size: "3"}, + Tag: `validate:"in=true"`, + }, + + { + FieldName: "FieldInStringMap", + Type: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + Tag: `validate:"in=a b c"`, + }, + + { + FieldName: "FieldInIntMap", + Type: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInInt8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInInt16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInInt32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInInt64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUintMap", + Type: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUint8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUint16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUint32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUint64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInFloat32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInFloat64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInBoolMap", + Type: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + Tag: `validate:"in=false"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=a b c`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=false`)}, + }, + }, + }, + want: `func inStructValidate(obj *inStruct) []error { +var errs []error +if !(obj.FieldInString == "ab" || obj.FieldInString == "cd" || obj.FieldInString == "ef") { +errs = append(errs, types.NewValidationError("FieldInString must be one of 'ab' 'cd' 'ef'")) +} +if !(obj.FieldInInt == 12 || obj.FieldInInt == 34 || obj.FieldInInt == 56) { +errs = append(errs, types.NewValidationError("FieldInInt must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt8 == 12 || obj.FieldInInt8 == 34 || obj.FieldInInt8 == 56) { +errs = append(errs, types.NewValidationError("FieldInInt8 must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt16 == 12 || obj.FieldInInt16 == 34 || obj.FieldInInt16 == 56) { +errs = append(errs, types.NewValidationError("FieldInInt16 must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt32 == 12 || obj.FieldInInt32 == 34 || obj.FieldInInt32 == 56) { +errs = append(errs, types.NewValidationError("FieldInInt32 must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt64 == 12 || obj.FieldInInt64 == 34 || obj.FieldInInt64 == 56) { +errs = append(errs, types.NewValidationError("FieldInInt64 must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint == 12 || obj.FieldInUint == 34 || obj.FieldInUint == 56) { +errs = append(errs, types.NewValidationError("FieldInUint must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint8 == 12 || obj.FieldInUint8 == 34 || obj.FieldInUint8 == 56) { +errs = append(errs, types.NewValidationError("FieldInUint8 must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint16 == 12 || obj.FieldInUint16 == 34 || obj.FieldInUint16 == 56) { +errs = append(errs, types.NewValidationError("FieldInUint16 must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint32 == 12 || obj.FieldInUint32 == 34 || obj.FieldInUint32 == 56) { +errs = append(errs, types.NewValidationError("FieldInUint32 must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint64 == 12 || obj.FieldInUint64 == 34 || obj.FieldInUint64 == 56) { +errs = append(errs, types.NewValidationError("FieldInUint64 must be one of '12' '34' '56'")) +} +if !(obj.FieldInFloat32 == 11.11 || obj.FieldInFloat32 == 22.22 || obj.FieldInFloat32 == 33.33) { +errs = append(errs, types.NewValidationError("FieldInFloat32 must be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldInFloat64 == 11.11 || obj.FieldInFloat64 == 22.22 || obj.FieldInFloat64 == 33.33) { +errs = append(errs, types.NewValidationError("FieldInFloat64 must be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldInBool == true) { +errs = append(errs, types.NewValidationError("FieldInBool must be one of 'true'")) +} +if !(types.SliceOnlyContains(obj.FieldInStringSlice, []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldInStringSlice elements must be one of 'ab' 'cd' 'ef'")) +} +if !(types.SliceOnlyContains(obj.FieldInIntSlice, []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInIntSlice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInInt8Slice, []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt8Slice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInInt16Slice, []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt16Slice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInInt32Slice, []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt32Slice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInInt64Slice, []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt64Slice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUintSlice, []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUintSlice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUint8Slice, []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint8Slice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUint16Slice, []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint16Slice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUint32Slice, []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint32Slice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUint64Slice, []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint64Slice elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInFloat32Slice, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32Slice elements must be one of '11.11' '22.22' '33.33'")) +} +if !(types.SliceOnlyContains(obj.FieldInFloat64Slice, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64Slice elements must be one of '11.11' '22.22' '33.33'")) +} +if !(types.SliceOnlyContains(obj.FieldInBoolSlice, []bool{true})) { +errs = append(errs, types.NewValidationError("FieldInBoolSlice elements must be one of 'true'")) +} +if !(types.SliceOnlyContains(obj.FieldInStringArray[:], []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldInStringArray elements must be one of 'ab' 'cd' 'ef'")) +} +if !(types.SliceOnlyContains(obj.FieldInIntArray[:], []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInIntArray elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInInt8Array[:], []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt8Array elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInInt16Array[:], []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt16Array elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInInt32Array[:], []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt32Array elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInInt64Array[:], []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt64Array elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUintArray[:], []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUintArray elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUint8Array[:], []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint8Array elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUint16Array[:], []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint16Array elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUint32Array[:], []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint32Array elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInUint64Array[:], []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint64Array elements must be one of '12' '34' '56'")) +} +if !(types.SliceOnlyContains(obj.FieldInFloat32Array[:], []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32Array elements must be one of '11.11' '22.22' '33.33'")) +} +if !(types.SliceOnlyContains(obj.FieldInFloat64Array[:], []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64Array elements must be one of '11.11' '22.22' '33.33'")) +} +if !(types.SliceOnlyContains(obj.FieldInBoolArray[:], []bool{true})) { +errs = append(errs, types.NewValidationError("FieldInBoolArray elements must be one of 'true'")) +} +if !(types.MapOnlyContains(obj.FieldInStringMap, []string{"a", "b", "c"})) { +errs = append(errs, types.NewValidationError("FieldInStringMap elements must be one of 'a' 'b' 'c'")) +} +if !(types.MapOnlyContains(obj.FieldInIntMap, []int{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInIntMap elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInInt8Map, []int8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt8Map elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInInt16Map, []int16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt16Map elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInInt32Map, []int32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt32Map elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInInt64Map, []int64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt64Map elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInUintMap, []uint{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUintMap elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInUint8Map, []uint8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint8Map elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInUint16Map, []uint16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint16Map elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInUint32Map, []uint32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint32Map elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInUint64Map, []uint64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint64Map elements must be one of '1' '2' '3'")) +} +if !(types.MapOnlyContains(obj.FieldInFloat32Map, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32Map elements must be one of '11.11' '22.22' '33.33'")) +} +if !(types.MapOnlyContains(obj.FieldInFloat64Map, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64Map elements must be one of '11.11' '22.22' '33.33'")) +} +if !(types.MapOnlyContains(obj.FieldInBoolMap, []bool{false})) { +errs = append(errs, types.NewValidationError("FieldInBoolMap elements must be one of 'false'")) +} +return errs +} +`, + }, + { + name: "ninStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "ninStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldNinString", + Type: common.FieldType{ComposedType: "", BaseType: "string", Size: ""}, + Tag: `validate:"nin=ab cd ef"`, + }, + + { + FieldName: "FieldNinInt", + Type: common.FieldType{ComposedType: "", BaseType: "int", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt8", + Type: common.FieldType{ComposedType: "", BaseType: "int8", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt16", + Type: common.FieldType{ComposedType: "", BaseType: "int16", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt32", + Type: common.FieldType{ComposedType: "", BaseType: "int32", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt64", + Type: common.FieldType{ComposedType: "", BaseType: "int64", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint", + Type: common.FieldType{ComposedType: "", BaseType: "uint", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint8", + Type: common.FieldType{ComposedType: "", BaseType: "uint8", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint16", + Type: common.FieldType{ComposedType: "", BaseType: "uint16", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint32", + Type: common.FieldType{ComposedType: "", BaseType: "uint32", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint64", + Type: common.FieldType{ComposedType: "", BaseType: "uint64", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinFloat32", + Type: common.FieldType{ComposedType: "", BaseType: "float32", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinFloat64", + Type: common.FieldType{ComposedType: "", BaseType: "float64", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinBool", + Type: common.FieldType{ComposedType: "", BaseType: "bool", Size: ""}, + Tag: `validate:"nin=true"`, + }, + + { + FieldName: "FieldNinStringSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "string", Size: ""}, + Tag: `validate:"nin=ab cd ef"`, + }, + + { + FieldName: "FieldNinIntSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int8", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int16", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int32", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "int64", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUintSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint8Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint16Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinFloat32Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float32", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinFloat64Slice", + Type: common.FieldType{ComposedType: "[]", BaseType: "float64", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinBoolSlice", + Type: common.FieldType{ComposedType: "[]", BaseType: "bool", Size: ""}, + Tag: `validate:"nin=true"`, + }, + + { + FieldName: "FieldNinStringArray", + Type: common.FieldType{ComposedType: "[N]", BaseType: "string", Size: "3"}, + Tag: `validate:"nin=ab cd ef"`, + }, + + { + FieldName: "FieldNinIntArray", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt8Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int8", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt16Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int16", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt32Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int32", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt64Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "int64", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUintArray", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint8Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint8", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint16Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint16", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint32Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint32", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint64Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "uint64", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinFloat32Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "float32", Size: "3"}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinFloat64Array", + Type: common.FieldType{ComposedType: "[N]", BaseType: "float64", Size: "3"}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinBoolArray", + Type: common.FieldType{ComposedType: "[N]", BaseType: "bool", Size: "3"}, + Tag: `validate:"nin=true"`, + }, + + { + FieldName: "FieldNinStringMap", + Type: common.FieldType{ComposedType: "map", BaseType: "string", Size: ""}, + Tag: `validate:"nin=a b c"`, + }, + + { + FieldName: "FieldNinIntMap", + Type: common.FieldType{ComposedType: "map", BaseType: "int", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinInt8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int8", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinInt16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int16", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinInt32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int32", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinInt64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "int64", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUintMap", + Type: common.FieldType{ComposedType: "map", BaseType: "uint", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUint8Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint8", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUint16Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint16", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUint32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint32", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUint64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "uint64", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinFloat32Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float32", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinFloat64Map", + Type: common.FieldType{ComposedType: "map", BaseType: "float64", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinBoolMap", + Type: common.FieldType{ComposedType: "map", BaseType: "bool", Size: ""}, + Tag: `validate:"nin=false"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=a b c`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=false`)}, + }, + }, + }, + want: `func ninStructValidate(obj *ninStruct) []error { +var errs []error +if !(obj.FieldNinString != "ab" && obj.FieldNinString != "cd" && obj.FieldNinString != "ef") { +errs = append(errs, types.NewValidationError("FieldNinString must not be one of 'ab' 'cd' 'ef'")) +} +if !(obj.FieldNinInt != 12 && obj.FieldNinInt != 34 && obj.FieldNinInt != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt8 != 12 && obj.FieldNinInt8 != 34 && obj.FieldNinInt8 != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt8 must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt16 != 12 && obj.FieldNinInt16 != 34 && obj.FieldNinInt16 != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt16 must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt32 != 12 && obj.FieldNinInt32 != 34 && obj.FieldNinInt32 != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt32 must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt64 != 12 && obj.FieldNinInt64 != 34 && obj.FieldNinInt64 != 56) { +errs = append(errs, types.NewValidationError("FieldNinInt64 must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint != 12 && obj.FieldNinUint != 34 && obj.FieldNinUint != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint8 != 12 && obj.FieldNinUint8 != 34 && obj.FieldNinUint8 != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint8 must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint16 != 12 && obj.FieldNinUint16 != 34 && obj.FieldNinUint16 != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint16 must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint32 != 12 && obj.FieldNinUint32 != 34 && obj.FieldNinUint32 != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint32 must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint64 != 12 && obj.FieldNinUint64 != 34 && obj.FieldNinUint64 != 56) { +errs = append(errs, types.NewValidationError("FieldNinUint64 must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinFloat32 != 11.11 && obj.FieldNinFloat32 != 22.22 && obj.FieldNinFloat32 != 33.33) { +errs = append(errs, types.NewValidationError("FieldNinFloat32 must not be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldNinFloat64 != 11.11 && obj.FieldNinFloat64 != 22.22 && obj.FieldNinFloat64 != 33.33) { +errs = append(errs, types.NewValidationError("FieldNinFloat64 must not be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldNinBool != true) { +errs = append(errs, types.NewValidationError("FieldNinBool must not be one of 'true'")) +} +if !(types.SliceNotContains(obj.FieldNinStringSlice, []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldNinStringSlice elements must not be one of 'ab' 'cd' 'ef'")) +} +if !(types.SliceNotContains(obj.FieldNinIntSlice, []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinIntSlice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinInt8Slice, []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt8Slice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinInt16Slice, []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt16Slice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinInt32Slice, []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt32Slice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinInt64Slice, []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt64Slice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUintSlice, []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUintSlice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUint8Slice, []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint8Slice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUint16Slice, []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint16Slice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUint32Slice, []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint32Slice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUint64Slice, []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint64Slice elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinFloat32Slice, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32Slice elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(types.SliceNotContains(obj.FieldNinFloat64Slice, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64Slice elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(types.SliceNotContains(obj.FieldNinBoolSlice, []bool{true})) { +errs = append(errs, types.NewValidationError("FieldNinBoolSlice elements must not be one of 'true'")) +} +if !(types.SliceNotContains(obj.FieldNinStringArray[:], []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldNinStringArray elements must not be one of 'ab' 'cd' 'ef'")) +} +if !(types.SliceNotContains(obj.FieldNinIntArray[:], []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinIntArray elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinInt8Array[:], []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt8Array elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinInt16Array[:], []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt16Array elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinInt32Array[:], []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt32Array elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinInt64Array[:], []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt64Array elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUintArray[:], []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUintArray elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUint8Array[:], []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint8Array elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUint16Array[:], []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint16Array elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUint32Array[:], []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint32Array elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinUint64Array[:], []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint64Array elements must not be one of '12' '34' '56'")) +} +if !(types.SliceNotContains(obj.FieldNinFloat32Array[:], []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32Array elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(types.SliceNotContains(obj.FieldNinFloat64Array[:], []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64Array elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(types.SliceNotContains(obj.FieldNinBoolArray[:], []bool{true})) { +errs = append(errs, types.NewValidationError("FieldNinBoolArray elements must not be one of 'true'")) +} +if !(types.MapNotContains(obj.FieldNinStringMap, []string{"a", "b", "c"})) { +errs = append(errs, types.NewValidationError("FieldNinStringMap elements must not be one of 'a' 'b' 'c'")) +} +if !(types.MapNotContains(obj.FieldNinIntMap, []int{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinIntMap elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinInt8Map, []int8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt8Map elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinInt16Map, []int16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt16Map elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinInt32Map, []int32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt32Map elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinInt64Map, []int64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt64Map elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinUintMap, []uint{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUintMap elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinUint8Map, []uint8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint8Map elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinUint16Map, []uint16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint16Map elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinUint32Map, []uint32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint32Map elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinUint64Map, []uint64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint64Map elements must not be one of '1' '2' '3'")) +} +if !(types.MapNotContains(obj.FieldNinFloat32Map, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32Map elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(types.MapNotContains(obj.FieldNinFloat64Map, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64Map elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(types.MapNotContains(obj.FieldNinBoolMap, []bool{false})) { +errs = append(errs, types.NewValidationError("FieldNinBoolMap elements must not be one of 'false'")) +} +return errs +} +`, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gv := GenValidations{ + Struct: tt.structInfo, + } + got, err := gv.BuildFuncValidatorCode() + if err != nil { + t.Errorf("FileValidator.GenerateValidator() error = %v, wantErr %v", err, nil) + return + } + if got != tt.want { + t.Errorf("FileValidator.GenerateValidator() = %v, want %v", got, tt.want) + dmp := diffmatchpatch.New() + diffs := dmp.DiffMain(tt.want, got, false) + if len(diffs) > 1 { + t.Errorf("FileValidator.GenerateValidator() diff = \n%v", dmp.DiffPrettyText(diffs)) + } + } + }) + } +} diff --git a/internal/codegenerator/generated_function_code_pointer_test.go b/internal/codegenerator/generated_function_code_pointer_test.go new file mode 100644 index 0000000..2288eb6 --- /dev/null +++ b/internal/codegenerator/generated_function_code_pointer_test.go @@ -0,0 +1,4654 @@ +// Code generated by TestGen. DO NOT EDIT. + +package codegenerator + +import ( + "testing" + + "github.com/opencodeco/validgen/internal/analyzer" + "github.com/opencodeco/validgen/internal/common" + "github.com/opencodeco/validgen/internal/parser" + "github.com/sergi/go-diff/diffmatchpatch" +) + +func TestBuildFunctionCodePointer(t *testing.T) { + tests := []struct { + name string + structInfo *analyzer.Struct + want string + }{ + { + name: "emailStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "emailStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldEmailStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"email"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `email`)}, + }, + }, + }, + want: `func emailStructValidate(obj *emailStruct) []error { +var errs []error +if !(obj.FieldEmailStringPointer != nil && types.IsValidEmail(*obj.FieldEmailStringPointer)) { +errs = append(errs, types.NewValidationError("FieldEmailStringPointer must be a valid email")) +} +return errs +} +`, + }, + { + name: "requiredStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "requiredStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldRequiredStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredIntPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUintPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredBoolPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredStringSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredIntSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUintSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredBoolSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredStringArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "string", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredIntArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt8ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int8", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt16ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int16", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt32ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int32", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt64ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int64", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUintArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint8ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint8", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint16ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint16", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint32ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint32", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint64ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint64", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat32ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "float32", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat64ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "float64", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredBoolArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "bool", Size: "3"}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredStringMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredIntMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredInt64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUintMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredUint64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredFloat64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + Tag: `validate:"required"`, + }, + + { + FieldName: "FieldRequiredBoolMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + Tag: `validate:"required"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `required`)}, + }, + }, + }, + want: `func requiredStructValidate(obj *requiredStruct) []error { +var errs []error +if !(obj.FieldRequiredStringPointer != nil && *obj.FieldRequiredStringPointer != "") { +errs = append(errs, types.NewValidationError("FieldRequiredStringPointer is required")) +} +if !(obj.FieldRequiredIntPointer != nil && *obj.FieldRequiredIntPointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntPointer is required")) +} +if !(obj.FieldRequiredInt8Pointer != nil && *obj.FieldRequiredInt8Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8Pointer is required")) +} +if !(obj.FieldRequiredInt16Pointer != nil && *obj.FieldRequiredInt16Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16Pointer is required")) +} +if !(obj.FieldRequiredInt32Pointer != nil && *obj.FieldRequiredInt32Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32Pointer is required")) +} +if !(obj.FieldRequiredInt64Pointer != nil && *obj.FieldRequiredInt64Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64Pointer is required")) +} +if !(obj.FieldRequiredUintPointer != nil && *obj.FieldRequiredUintPointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintPointer is required")) +} +if !(obj.FieldRequiredUint8Pointer != nil && *obj.FieldRequiredUint8Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8Pointer is required")) +} +if !(obj.FieldRequiredUint16Pointer != nil && *obj.FieldRequiredUint16Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16Pointer is required")) +} +if !(obj.FieldRequiredUint32Pointer != nil && *obj.FieldRequiredUint32Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32Pointer is required")) +} +if !(obj.FieldRequiredUint64Pointer != nil && *obj.FieldRequiredUint64Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64Pointer is required")) +} +if !(obj.FieldRequiredFloat32Pointer != nil && *obj.FieldRequiredFloat32Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32Pointer is required")) +} +if !(obj.FieldRequiredFloat64Pointer != nil && *obj.FieldRequiredFloat64Pointer != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64Pointer is required")) +} +if !(obj.FieldRequiredBoolPointer != nil && *obj.FieldRequiredBoolPointer != false) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolPointer is required")) +} +if !(obj.FieldRequiredStringSlicePointer != nil && len(*obj.FieldRequiredStringSlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredStringSlicePointer must not be empty")) +} +if !(obj.FieldRequiredIntSlicePointer != nil && len(*obj.FieldRequiredIntSlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntSlicePointer must not be empty")) +} +if !(obj.FieldRequiredInt8SlicePointer != nil && len(*obj.FieldRequiredInt8SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8SlicePointer must not be empty")) +} +if !(obj.FieldRequiredInt16SlicePointer != nil && len(*obj.FieldRequiredInt16SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16SlicePointer must not be empty")) +} +if !(obj.FieldRequiredInt32SlicePointer != nil && len(*obj.FieldRequiredInt32SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32SlicePointer must not be empty")) +} +if !(obj.FieldRequiredInt64SlicePointer != nil && len(*obj.FieldRequiredInt64SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64SlicePointer must not be empty")) +} +if !(obj.FieldRequiredUintSlicePointer != nil && len(*obj.FieldRequiredUintSlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintSlicePointer must not be empty")) +} +if !(obj.FieldRequiredUint8SlicePointer != nil && len(*obj.FieldRequiredUint8SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8SlicePointer must not be empty")) +} +if !(obj.FieldRequiredUint16SlicePointer != nil && len(*obj.FieldRequiredUint16SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16SlicePointer must not be empty")) +} +if !(obj.FieldRequiredUint32SlicePointer != nil && len(*obj.FieldRequiredUint32SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32SlicePointer must not be empty")) +} +if !(obj.FieldRequiredUint64SlicePointer != nil && len(*obj.FieldRequiredUint64SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64SlicePointer must not be empty")) +} +if !(obj.FieldRequiredFloat32SlicePointer != nil && len(*obj.FieldRequiredFloat32SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32SlicePointer must not be empty")) +} +if !(obj.FieldRequiredFloat64SlicePointer != nil && len(*obj.FieldRequiredFloat64SlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64SlicePointer must not be empty")) +} +if !(obj.FieldRequiredBoolSlicePointer != nil && len(*obj.FieldRequiredBoolSlicePointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolSlicePointer must not be empty")) +} +if !(obj.FieldRequiredStringArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredStringArrayPointer must not be empty")) +} +if !(obj.FieldRequiredIntArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredIntArrayPointer must not be empty")) +} +if !(obj.FieldRequiredInt8ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredInt16ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredInt32ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredInt64ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredUintArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUintArrayPointer must not be empty")) +} +if !(obj.FieldRequiredUint8ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredUint16ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredUint32ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredUint64ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredFloat32ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredFloat64ArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64ArrayPointer must not be empty")) +} +if !(obj.FieldRequiredBoolArrayPointer != nil) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolArrayPointer must not be empty")) +} +if !(obj.FieldRequiredStringMapPointer != nil && len(*obj.FieldRequiredStringMapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredStringMapPointer must not be empty")) +} +if !(obj.FieldRequiredIntMapPointer != nil && len(*obj.FieldRequiredIntMapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredIntMapPointer must not be empty")) +} +if !(obj.FieldRequiredInt8MapPointer != nil && len(*obj.FieldRequiredInt8MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt8MapPointer must not be empty")) +} +if !(obj.FieldRequiredInt16MapPointer != nil && len(*obj.FieldRequiredInt16MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt16MapPointer must not be empty")) +} +if !(obj.FieldRequiredInt32MapPointer != nil && len(*obj.FieldRequiredInt32MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt32MapPointer must not be empty")) +} +if !(obj.FieldRequiredInt64MapPointer != nil && len(*obj.FieldRequiredInt64MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredInt64MapPointer must not be empty")) +} +if !(obj.FieldRequiredUintMapPointer != nil && len(*obj.FieldRequiredUintMapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUintMapPointer must not be empty")) +} +if !(obj.FieldRequiredUint8MapPointer != nil && len(*obj.FieldRequiredUint8MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint8MapPointer must not be empty")) +} +if !(obj.FieldRequiredUint16MapPointer != nil && len(*obj.FieldRequiredUint16MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint16MapPointer must not be empty")) +} +if !(obj.FieldRequiredUint32MapPointer != nil && len(*obj.FieldRequiredUint32MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint32MapPointer must not be empty")) +} +if !(obj.FieldRequiredUint64MapPointer != nil && len(*obj.FieldRequiredUint64MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredUint64MapPointer must not be empty")) +} +if !(obj.FieldRequiredFloat32MapPointer != nil && len(*obj.FieldRequiredFloat32MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat32MapPointer must not be empty")) +} +if !(obj.FieldRequiredFloat64MapPointer != nil && len(*obj.FieldRequiredFloat64MapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredFloat64MapPointer must not be empty")) +} +if !(obj.FieldRequiredBoolMapPointer != nil && len(*obj.FieldRequiredBoolMapPointer) != 0) { +errs = append(errs, types.NewValidationError("FieldRequiredBoolMapPointer must not be empty")) +} +return errs +} +`, + }, + { + name: "eqStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "eqStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldEqStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"eq=abcde"`, + }, + + { + FieldName: "FieldEqIntPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqInt8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqInt16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqInt32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqInt64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUintPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUint8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUint16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUint32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqUint64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + Tag: `validate:"eq=32"`, + }, + + { + FieldName: "FieldEqFloat32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + Tag: `validate:"eq=12.34"`, + }, + + { + FieldName: "FieldEqFloat64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + Tag: `validate:"eq=12.34"`, + }, + + { + FieldName: "FieldEqBoolPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + Tag: `validate:"eq=true"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=abcde`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq=true`)}, + }, + }, + }, + want: `func eqStructValidate(obj *eqStruct) []error { +var errs []error +if !(obj.FieldEqStringPointer != nil && *obj.FieldEqStringPointer == "abcde") { +errs = append(errs, types.NewValidationError("FieldEqStringPointer must be equal to 'abcde'")) +} +if !(obj.FieldEqIntPointer != nil && *obj.FieldEqIntPointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqIntPointer must be equal to 32")) +} +if !(obj.FieldEqInt8Pointer != nil && *obj.FieldEqInt8Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt8Pointer must be equal to 32")) +} +if !(obj.FieldEqInt16Pointer != nil && *obj.FieldEqInt16Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt16Pointer must be equal to 32")) +} +if !(obj.FieldEqInt32Pointer != nil && *obj.FieldEqInt32Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt32Pointer must be equal to 32")) +} +if !(obj.FieldEqInt64Pointer != nil && *obj.FieldEqInt64Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqInt64Pointer must be equal to 32")) +} +if !(obj.FieldEqUintPointer != nil && *obj.FieldEqUintPointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUintPointer must be equal to 32")) +} +if !(obj.FieldEqUint8Pointer != nil && *obj.FieldEqUint8Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint8Pointer must be equal to 32")) +} +if !(obj.FieldEqUint16Pointer != nil && *obj.FieldEqUint16Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint16Pointer must be equal to 32")) +} +if !(obj.FieldEqUint32Pointer != nil && *obj.FieldEqUint32Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint32Pointer must be equal to 32")) +} +if !(obj.FieldEqUint64Pointer != nil && *obj.FieldEqUint64Pointer == 32) { +errs = append(errs, types.NewValidationError("FieldEqUint64Pointer must be equal to 32")) +} +if !(obj.FieldEqFloat32Pointer != nil && *obj.FieldEqFloat32Pointer == 12.34) { +errs = append(errs, types.NewValidationError("FieldEqFloat32Pointer must be equal to 12.34")) +} +if !(obj.FieldEqFloat64Pointer != nil && *obj.FieldEqFloat64Pointer == 12.34) { +errs = append(errs, types.NewValidationError("FieldEqFloat64Pointer must be equal to 12.34")) +} +if !(obj.FieldEqBoolPointer != nil && *obj.FieldEqBoolPointer == true) { +errs = append(errs, types.NewValidationError("FieldEqBoolPointer must be equal to true")) +} +return errs +} +`, + }, + { + name: "neqStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "neqStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldNeqStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"neq=abcde"`, + }, + + { + FieldName: "FieldNeqIntPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqInt8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqInt16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqInt32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqInt64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUintPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUint8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUint16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUint32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqUint64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + Tag: `validate:"neq=32"`, + }, + + { + FieldName: "FieldNeqFloat32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + Tag: `validate:"neq=12.34"`, + }, + + { + FieldName: "FieldNeqFloat64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + Tag: `validate:"neq=12.34"`, + }, + + { + FieldName: "FieldNeqBoolPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + Tag: `validate:"neq=true"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=abcde`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq=true`)}, + }, + }, + }, + want: `func neqStructValidate(obj *neqStruct) []error { +var errs []error +if !(obj.FieldNeqStringPointer != nil && *obj.FieldNeqStringPointer != "abcde") { +errs = append(errs, types.NewValidationError("FieldNeqStringPointer must not be equal to 'abcde'")) +} +if !(obj.FieldNeqIntPointer != nil && *obj.FieldNeqIntPointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqIntPointer must not be equal to 32")) +} +if !(obj.FieldNeqInt8Pointer != nil && *obj.FieldNeqInt8Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt8Pointer must not be equal to 32")) +} +if !(obj.FieldNeqInt16Pointer != nil && *obj.FieldNeqInt16Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt16Pointer must not be equal to 32")) +} +if !(obj.FieldNeqInt32Pointer != nil && *obj.FieldNeqInt32Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt32Pointer must not be equal to 32")) +} +if !(obj.FieldNeqInt64Pointer != nil && *obj.FieldNeqInt64Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqInt64Pointer must not be equal to 32")) +} +if !(obj.FieldNeqUintPointer != nil && *obj.FieldNeqUintPointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUintPointer must not be equal to 32")) +} +if !(obj.FieldNeqUint8Pointer != nil && *obj.FieldNeqUint8Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint8Pointer must not be equal to 32")) +} +if !(obj.FieldNeqUint16Pointer != nil && *obj.FieldNeqUint16Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint16Pointer must not be equal to 32")) +} +if !(obj.FieldNeqUint32Pointer != nil && *obj.FieldNeqUint32Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint32Pointer must not be equal to 32")) +} +if !(obj.FieldNeqUint64Pointer != nil && *obj.FieldNeqUint64Pointer != 32) { +errs = append(errs, types.NewValidationError("FieldNeqUint64Pointer must not be equal to 32")) +} +if !(obj.FieldNeqFloat32Pointer != nil && *obj.FieldNeqFloat32Pointer != 12.34) { +errs = append(errs, types.NewValidationError("FieldNeqFloat32Pointer must not be equal to 12.34")) +} +if !(obj.FieldNeqFloat64Pointer != nil && *obj.FieldNeqFloat64Pointer != 12.34) { +errs = append(errs, types.NewValidationError("FieldNeqFloat64Pointer must not be equal to 12.34")) +} +if !(obj.FieldNeqBoolPointer != nil && *obj.FieldNeqBoolPointer != true) { +errs = append(errs, types.NewValidationError("FieldNeqBoolPointer must not be equal to true")) +} +return errs +} +`, + }, + { + name: "gtStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "gtStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldGtIntPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtInt8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtInt16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtInt32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtInt64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUintPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUint8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUint16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUint32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtUint64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + Tag: `validate:"gt=32"`, + }, + + { + FieldName: "FieldGtFloat32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + Tag: `validate:"gt=12.34"`, + }, + + { + FieldName: "FieldGtFloat64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + Tag: `validate:"gt=12.34"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gt=12.34`)}, + }, + }, + }, + want: `func gtStructValidate(obj *gtStruct) []error { +var errs []error +if !(obj.FieldGtIntPointer != nil && *obj.FieldGtIntPointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtIntPointer must be > 32")) +} +if !(obj.FieldGtInt8Pointer != nil && *obj.FieldGtInt8Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt8Pointer must be > 32")) +} +if !(obj.FieldGtInt16Pointer != nil && *obj.FieldGtInt16Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt16Pointer must be > 32")) +} +if !(obj.FieldGtInt32Pointer != nil && *obj.FieldGtInt32Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt32Pointer must be > 32")) +} +if !(obj.FieldGtInt64Pointer != nil && *obj.FieldGtInt64Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtInt64Pointer must be > 32")) +} +if !(obj.FieldGtUintPointer != nil && *obj.FieldGtUintPointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUintPointer must be > 32")) +} +if !(obj.FieldGtUint8Pointer != nil && *obj.FieldGtUint8Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint8Pointer must be > 32")) +} +if !(obj.FieldGtUint16Pointer != nil && *obj.FieldGtUint16Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint16Pointer must be > 32")) +} +if !(obj.FieldGtUint32Pointer != nil && *obj.FieldGtUint32Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint32Pointer must be > 32")) +} +if !(obj.FieldGtUint64Pointer != nil && *obj.FieldGtUint64Pointer > 32) { +errs = append(errs, types.NewValidationError("FieldGtUint64Pointer must be > 32")) +} +if !(obj.FieldGtFloat32Pointer != nil && *obj.FieldGtFloat32Pointer > 12.34) { +errs = append(errs, types.NewValidationError("FieldGtFloat32Pointer must be > 12.34")) +} +if !(obj.FieldGtFloat64Pointer != nil && *obj.FieldGtFloat64Pointer > 12.34) { +errs = append(errs, types.NewValidationError("FieldGtFloat64Pointer must be > 12.34")) +} +return errs +} +`, + }, + { + name: "gteStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "gteStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldGteIntPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteInt8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteInt16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteInt32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteInt64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUintPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUint8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUint16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUint32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteUint64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + Tag: `validate:"gte=32"`, + }, + + { + FieldName: "FieldGteFloat32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + Tag: `validate:"gte=12.34"`, + }, + + { + FieldName: "FieldGteFloat64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + Tag: `validate:"gte=12.34"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `gte=12.34`)}, + }, + }, + }, + want: `func gteStructValidate(obj *gteStruct) []error { +var errs []error +if !(obj.FieldGteIntPointer != nil && *obj.FieldGteIntPointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteIntPointer must be >= 32")) +} +if !(obj.FieldGteInt8Pointer != nil && *obj.FieldGteInt8Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt8Pointer must be >= 32")) +} +if !(obj.FieldGteInt16Pointer != nil && *obj.FieldGteInt16Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt16Pointer must be >= 32")) +} +if !(obj.FieldGteInt32Pointer != nil && *obj.FieldGteInt32Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt32Pointer must be >= 32")) +} +if !(obj.FieldGteInt64Pointer != nil && *obj.FieldGteInt64Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteInt64Pointer must be >= 32")) +} +if !(obj.FieldGteUintPointer != nil && *obj.FieldGteUintPointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUintPointer must be >= 32")) +} +if !(obj.FieldGteUint8Pointer != nil && *obj.FieldGteUint8Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint8Pointer must be >= 32")) +} +if !(obj.FieldGteUint16Pointer != nil && *obj.FieldGteUint16Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint16Pointer must be >= 32")) +} +if !(obj.FieldGteUint32Pointer != nil && *obj.FieldGteUint32Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint32Pointer must be >= 32")) +} +if !(obj.FieldGteUint64Pointer != nil && *obj.FieldGteUint64Pointer >= 32) { +errs = append(errs, types.NewValidationError("FieldGteUint64Pointer must be >= 32")) +} +if !(obj.FieldGteFloat32Pointer != nil && *obj.FieldGteFloat32Pointer >= 12.34) { +errs = append(errs, types.NewValidationError("FieldGteFloat32Pointer must be >= 12.34")) +} +if !(obj.FieldGteFloat64Pointer != nil && *obj.FieldGteFloat64Pointer >= 12.34) { +errs = append(errs, types.NewValidationError("FieldGteFloat64Pointer must be >= 12.34")) +} +return errs +} +`, + }, + { + name: "ltStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "ltStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldLtIntPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtInt8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtInt16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtInt32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtInt64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUintPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUint8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUint16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUint32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtUint64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + Tag: `validate:"lt=32"`, + }, + + { + FieldName: "FieldLtFloat32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + Tag: `validate:"lt=12.34"`, + }, + + { + FieldName: "FieldLtFloat64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + Tag: `validate:"lt=12.34"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lt=12.34`)}, + }, + }, + }, + want: `func ltStructValidate(obj *ltStruct) []error { +var errs []error +if !(obj.FieldLtIntPointer != nil && *obj.FieldLtIntPointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtIntPointer must be < 32")) +} +if !(obj.FieldLtInt8Pointer != nil && *obj.FieldLtInt8Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt8Pointer must be < 32")) +} +if !(obj.FieldLtInt16Pointer != nil && *obj.FieldLtInt16Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt16Pointer must be < 32")) +} +if !(obj.FieldLtInt32Pointer != nil && *obj.FieldLtInt32Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt32Pointer must be < 32")) +} +if !(obj.FieldLtInt64Pointer != nil && *obj.FieldLtInt64Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtInt64Pointer must be < 32")) +} +if !(obj.FieldLtUintPointer != nil && *obj.FieldLtUintPointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUintPointer must be < 32")) +} +if !(obj.FieldLtUint8Pointer != nil && *obj.FieldLtUint8Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint8Pointer must be < 32")) +} +if !(obj.FieldLtUint16Pointer != nil && *obj.FieldLtUint16Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint16Pointer must be < 32")) +} +if !(obj.FieldLtUint32Pointer != nil && *obj.FieldLtUint32Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint32Pointer must be < 32")) +} +if !(obj.FieldLtUint64Pointer != nil && *obj.FieldLtUint64Pointer < 32) { +errs = append(errs, types.NewValidationError("FieldLtUint64Pointer must be < 32")) +} +if !(obj.FieldLtFloat32Pointer != nil && *obj.FieldLtFloat32Pointer < 12.34) { +errs = append(errs, types.NewValidationError("FieldLtFloat32Pointer must be < 12.34")) +} +if !(obj.FieldLtFloat64Pointer != nil && *obj.FieldLtFloat64Pointer < 12.34) { +errs = append(errs, types.NewValidationError("FieldLtFloat64Pointer must be < 12.34")) +} +return errs +} +`, + }, + { + name: "lteStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "lteStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldLteIntPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteInt8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteInt16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteInt32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteInt64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUintPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUint8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUint16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUint32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteUint64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + Tag: `validate:"lte=32"`, + }, + + { + FieldName: "FieldLteFloat32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + Tag: `validate:"lte=12.34"`, + }, + + { + FieldName: "FieldLteFloat64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + Tag: `validate:"lte=12.34"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=32`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=12.34`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `lte=12.34`)}, + }, + }, + }, + want: `func lteStructValidate(obj *lteStruct) []error { +var errs []error +if !(obj.FieldLteIntPointer != nil && *obj.FieldLteIntPointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteIntPointer must be <= 32")) +} +if !(obj.FieldLteInt8Pointer != nil && *obj.FieldLteInt8Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt8Pointer must be <= 32")) +} +if !(obj.FieldLteInt16Pointer != nil && *obj.FieldLteInt16Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt16Pointer must be <= 32")) +} +if !(obj.FieldLteInt32Pointer != nil && *obj.FieldLteInt32Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt32Pointer must be <= 32")) +} +if !(obj.FieldLteInt64Pointer != nil && *obj.FieldLteInt64Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteInt64Pointer must be <= 32")) +} +if !(obj.FieldLteUintPointer != nil && *obj.FieldLteUintPointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUintPointer must be <= 32")) +} +if !(obj.FieldLteUint8Pointer != nil && *obj.FieldLteUint8Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint8Pointer must be <= 32")) +} +if !(obj.FieldLteUint16Pointer != nil && *obj.FieldLteUint16Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint16Pointer must be <= 32")) +} +if !(obj.FieldLteUint32Pointer != nil && *obj.FieldLteUint32Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint32Pointer must be <= 32")) +} +if !(obj.FieldLteUint64Pointer != nil && *obj.FieldLteUint64Pointer <= 32) { +errs = append(errs, types.NewValidationError("FieldLteUint64Pointer must be <= 32")) +} +if !(obj.FieldLteFloat32Pointer != nil && *obj.FieldLteFloat32Pointer <= 12.34) { +errs = append(errs, types.NewValidationError("FieldLteFloat32Pointer must be <= 12.34")) +} +if !(obj.FieldLteFloat64Pointer != nil && *obj.FieldLteFloat64Pointer <= 12.34) { +errs = append(errs, types.NewValidationError("FieldLteFloat64Pointer must be <= 12.34")) +} +return errs +} +`, + }, + { + name: "minStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "minStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldMinStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"min=5"`, + }, + + { + FieldName: "FieldMinStringSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinIntSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUintSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinFloat32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinFloat64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinBoolSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinStringMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinIntMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinInt64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUintMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinUint64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinFloat32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinFloat64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + Tag: `validate:"min=2"`, + }, + + { + FieldName: "FieldMinBoolMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + Tag: `validate:"min=2"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=5`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `min=2`)}, + }, + }, + }, + want: `func minStructValidate(obj *minStruct) []error { +var errs []error +if !(obj.FieldMinStringPointer != nil && len(*obj.FieldMinStringPointer) >= 5) { +errs = append(errs, types.NewValidationError("FieldMinStringPointer length must be >= 5")) +} +if !(obj.FieldMinStringSlicePointer != nil && len(*obj.FieldMinStringSlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinStringSlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinIntSlicePointer != nil && len(*obj.FieldMinIntSlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinIntSlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinInt8SlicePointer != nil && len(*obj.FieldMinInt8SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt8SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinInt16SlicePointer != nil && len(*obj.FieldMinInt16SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt16SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinInt32SlicePointer != nil && len(*obj.FieldMinInt32SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt32SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinInt64SlicePointer != nil && len(*obj.FieldMinInt64SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt64SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinUintSlicePointer != nil && len(*obj.FieldMinUintSlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUintSlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinUint8SlicePointer != nil && len(*obj.FieldMinUint8SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint8SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinUint16SlicePointer != nil && len(*obj.FieldMinUint16SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint16SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinUint32SlicePointer != nil && len(*obj.FieldMinUint32SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint32SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinUint64SlicePointer != nil && len(*obj.FieldMinUint64SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint64SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinFloat32SlicePointer != nil && len(*obj.FieldMinFloat32SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat32SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinFloat64SlicePointer != nil && len(*obj.FieldMinFloat64SlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat64SlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinBoolSlicePointer != nil && len(*obj.FieldMinBoolSlicePointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinBoolSlicePointer must have at least 2 elements")) +} +if !(obj.FieldMinStringMapPointer != nil && len(*obj.FieldMinStringMapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinStringMapPointer must have at least 2 elements")) +} +if !(obj.FieldMinIntMapPointer != nil && len(*obj.FieldMinIntMapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinIntMapPointer must have at least 2 elements")) +} +if !(obj.FieldMinInt8MapPointer != nil && len(*obj.FieldMinInt8MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt8MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinInt16MapPointer != nil && len(*obj.FieldMinInt16MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt16MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinInt32MapPointer != nil && len(*obj.FieldMinInt32MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt32MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinInt64MapPointer != nil && len(*obj.FieldMinInt64MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinInt64MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinUintMapPointer != nil && len(*obj.FieldMinUintMapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUintMapPointer must have at least 2 elements")) +} +if !(obj.FieldMinUint8MapPointer != nil && len(*obj.FieldMinUint8MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint8MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinUint16MapPointer != nil && len(*obj.FieldMinUint16MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint16MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinUint32MapPointer != nil && len(*obj.FieldMinUint32MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint32MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinUint64MapPointer != nil && len(*obj.FieldMinUint64MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinUint64MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinFloat32MapPointer != nil && len(*obj.FieldMinFloat32MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat32MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinFloat64MapPointer != nil && len(*obj.FieldMinFloat64MapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinFloat64MapPointer must have at least 2 elements")) +} +if !(obj.FieldMinBoolMapPointer != nil && len(*obj.FieldMinBoolMapPointer) >= 2) { +errs = append(errs, types.NewValidationError("FieldMinBoolMapPointer must have at least 2 elements")) +} +return errs +} +`, + }, + { + name: "maxStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "maxStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldMaxStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"max=3"`, + }, + + { + FieldName: "FieldMaxStringSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxIntSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUintSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxFloat32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxFloat64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxBoolSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxStringMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxIntMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxInt64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUintMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxUint64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxFloat32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxFloat64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + Tag: `validate:"max=2"`, + }, + + { + FieldName: "FieldMaxBoolMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + Tag: `validate:"max=1"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `max=1`)}, + }, + }, + }, + want: `func maxStructValidate(obj *maxStruct) []error { +var errs []error +if !(obj.FieldMaxStringPointer != nil && len(*obj.FieldMaxStringPointer) <= 3) { +errs = append(errs, types.NewValidationError("FieldMaxStringPointer length must be <= 3")) +} +if !(obj.FieldMaxStringSlicePointer != nil && len(*obj.FieldMaxStringSlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxStringSlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxIntSlicePointer != nil && len(*obj.FieldMaxIntSlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxIntSlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxInt8SlicePointer != nil && len(*obj.FieldMaxInt8SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt8SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxInt16SlicePointer != nil && len(*obj.FieldMaxInt16SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt16SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxInt32SlicePointer != nil && len(*obj.FieldMaxInt32SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt32SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxInt64SlicePointer != nil && len(*obj.FieldMaxInt64SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt64SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxUintSlicePointer != nil && len(*obj.FieldMaxUintSlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUintSlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxUint8SlicePointer != nil && len(*obj.FieldMaxUint8SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint8SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxUint16SlicePointer != nil && len(*obj.FieldMaxUint16SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint16SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxUint32SlicePointer != nil && len(*obj.FieldMaxUint32SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint32SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxUint64SlicePointer != nil && len(*obj.FieldMaxUint64SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint64SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxFloat32SlicePointer != nil && len(*obj.FieldMaxFloat32SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat32SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxFloat64SlicePointer != nil && len(*obj.FieldMaxFloat64SlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat64SlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxBoolSlicePointer != nil && len(*obj.FieldMaxBoolSlicePointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxBoolSlicePointer must have at most 2 elements")) +} +if !(obj.FieldMaxStringMapPointer != nil && len(*obj.FieldMaxStringMapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxStringMapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxIntMapPointer != nil && len(*obj.FieldMaxIntMapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxIntMapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxInt8MapPointer != nil && len(*obj.FieldMaxInt8MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt8MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxInt16MapPointer != nil && len(*obj.FieldMaxInt16MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt16MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxInt32MapPointer != nil && len(*obj.FieldMaxInt32MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt32MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxInt64MapPointer != nil && len(*obj.FieldMaxInt64MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxInt64MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxUintMapPointer != nil && len(*obj.FieldMaxUintMapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUintMapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxUint8MapPointer != nil && len(*obj.FieldMaxUint8MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint8MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxUint16MapPointer != nil && len(*obj.FieldMaxUint16MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint16MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxUint32MapPointer != nil && len(*obj.FieldMaxUint32MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint32MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxUint64MapPointer != nil && len(*obj.FieldMaxUint64MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxUint64MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxFloat32MapPointer != nil && len(*obj.FieldMaxFloat32MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat32MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxFloat64MapPointer != nil && len(*obj.FieldMaxFloat64MapPointer) <= 2) { +errs = append(errs, types.NewValidationError("FieldMaxFloat64MapPointer must have at most 2 elements")) +} +if !(obj.FieldMaxBoolMapPointer != nil && len(*obj.FieldMaxBoolMapPointer) <= 1) { +errs = append(errs, types.NewValidationError("FieldMaxBoolMapPointer must have at most 1 elements")) +} +return errs +} +`, + }, + { + name: "eq_ignore_caseStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "eq_ignore_caseStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldEq_ignore_caseStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"eq_ignore_case=abcde"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `eq_ignore_case=abcde`)}, + }, + }, + }, + want: `func eq_ignore_caseStructValidate(obj *eq_ignore_caseStruct) []error { +var errs []error +if !(obj.FieldEq_ignore_caseStringPointer != nil && types.EqualFold(*obj.FieldEq_ignore_caseStringPointer, "abcde")) { +errs = append(errs, types.NewValidationError("FieldEq_ignore_caseStringPointer must be equal to 'abcde'")) +} +return errs +} +`, + }, + { + name: "neq_ignore_caseStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "neq_ignore_caseStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldNeq_ignore_caseStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"neq_ignore_case=abcde"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `neq_ignore_case=abcde`)}, + }, + }, + }, + want: `func neq_ignore_caseStructValidate(obj *neq_ignore_caseStruct) []error { +var errs []error +if !(obj.FieldNeq_ignore_caseStringPointer != nil && !types.EqualFold(*obj.FieldNeq_ignore_caseStringPointer, "abcde")) { +errs = append(errs, types.NewValidationError("FieldNeq_ignore_caseStringPointer must not be equal to 'abcde'")) +} +return errs +} +`, + }, + { + name: "lenStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "lenStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldLenStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenStringSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenIntSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUintSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenFloat32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenFloat64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenBoolSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenStringMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenIntMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenInt64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUintMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenUint64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenFloat32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenFloat64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + Tag: `validate:"len=2"`, + }, + + { + FieldName: "FieldLenBoolMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + Tag: `validate:"len=2"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `len=2`)}, + }, + }, + }, + want: `func lenStructValidate(obj *lenStruct) []error { +var errs []error +if !(obj.FieldLenStringPointer != nil && len(*obj.FieldLenStringPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringPointer length must be 2")) +} +if !(obj.FieldLenStringSlicePointer != nil && len(*obj.FieldLenStringSlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringSlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenIntSlicePointer != nil && len(*obj.FieldLenIntSlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenIntSlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenInt8SlicePointer != nil && len(*obj.FieldLenInt8SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt8SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenInt16SlicePointer != nil && len(*obj.FieldLenInt16SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt16SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenInt32SlicePointer != nil && len(*obj.FieldLenInt32SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt32SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenInt64SlicePointer != nil && len(*obj.FieldLenInt64SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt64SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenUintSlicePointer != nil && len(*obj.FieldLenUintSlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUintSlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenUint8SlicePointer != nil && len(*obj.FieldLenUint8SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint8SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenUint16SlicePointer != nil && len(*obj.FieldLenUint16SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint16SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenUint32SlicePointer != nil && len(*obj.FieldLenUint32SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint32SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenUint64SlicePointer != nil && len(*obj.FieldLenUint64SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint64SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenFloat32SlicePointer != nil && len(*obj.FieldLenFloat32SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat32SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenFloat64SlicePointer != nil && len(*obj.FieldLenFloat64SlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat64SlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenBoolSlicePointer != nil && len(*obj.FieldLenBoolSlicePointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenBoolSlicePointer must have exactly 2 elements")) +} +if !(obj.FieldLenStringMapPointer != nil && len(*obj.FieldLenStringMapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenStringMapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenIntMapPointer != nil && len(*obj.FieldLenIntMapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenIntMapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenInt8MapPointer != nil && len(*obj.FieldLenInt8MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt8MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenInt16MapPointer != nil && len(*obj.FieldLenInt16MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt16MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenInt32MapPointer != nil && len(*obj.FieldLenInt32MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt32MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenInt64MapPointer != nil && len(*obj.FieldLenInt64MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenInt64MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenUintMapPointer != nil && len(*obj.FieldLenUintMapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUintMapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenUint8MapPointer != nil && len(*obj.FieldLenUint8MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint8MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenUint16MapPointer != nil && len(*obj.FieldLenUint16MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint16MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenUint32MapPointer != nil && len(*obj.FieldLenUint32MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint32MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenUint64MapPointer != nil && len(*obj.FieldLenUint64MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenUint64MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenFloat32MapPointer != nil && len(*obj.FieldLenFloat32MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat32MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenFloat64MapPointer != nil && len(*obj.FieldLenFloat64MapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenFloat64MapPointer must have exactly 2 elements")) +} +if !(obj.FieldLenBoolMapPointer != nil && len(*obj.FieldLenBoolMapPointer) == 2) { +errs = append(errs, types.NewValidationError("FieldLenBoolMapPointer must have exactly 2 elements")) +} +return errs +} +`, + }, + { + name: "inStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "inStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldInStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"in=ab cd ef"`, + }, + + { + FieldName: "FieldInIntPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUintPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInFloat32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInFloat64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInBoolPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + Tag: `validate:"in=true"`, + }, + + { + FieldName: "FieldInStringSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + Tag: `validate:"in=ab cd ef"`, + }, + + { + FieldName: "FieldInIntSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUintSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInFloat32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInFloat64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInBoolSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + Tag: `validate:"in=true"`, + }, + + { + FieldName: "FieldInStringArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "string", Size: "3"}, + Tag: `validate:"in=ab cd ef"`, + }, + + { + FieldName: "FieldInIntArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt8ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int8", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt16ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int16", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt32ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int32", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInInt64ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int64", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUintArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint8ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint8", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint16ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint16", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint32ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint32", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInUint64ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint64", Size: "3"}, + Tag: `validate:"in=12 34 56"`, + }, + + { + FieldName: "FieldInFloat32ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "float32", Size: "3"}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInFloat64ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "float64", Size: "3"}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInBoolArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "bool", Size: "3"}, + Tag: `validate:"in=true"`, + }, + + { + FieldName: "FieldInStringMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + Tag: `validate:"in=a b c"`, + }, + + { + FieldName: "FieldInIntMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInInt8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInInt16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInInt32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInInt64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUintMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUint8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUint16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUint32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInUint64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + Tag: `validate:"in=1 2 3"`, + }, + + { + FieldName: "FieldInFloat32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInFloat64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + Tag: `validate:"in=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldInBoolMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + Tag: `validate:"in=false"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=a b c`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `in=false`)}, + }, + }, + }, + want: `func inStructValidate(obj *inStruct) []error { +var errs []error +if !((obj.FieldInStringPointer != nil && *obj.FieldInStringPointer == "ab") || (obj.FieldInStringPointer != nil && *obj.FieldInStringPointer == "cd") || (obj.FieldInStringPointer != nil && *obj.FieldInStringPointer == "ef")) { +errs = append(errs, types.NewValidationError("FieldInStringPointer must be one of 'ab' 'cd' 'ef'")) +} +if !((obj.FieldInIntPointer != nil && *obj.FieldInIntPointer == 12) || (obj.FieldInIntPointer != nil && *obj.FieldInIntPointer == 34) || (obj.FieldInIntPointer != nil && *obj.FieldInIntPointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInIntPointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInInt8Pointer != nil && *obj.FieldInInt8Pointer == 12) || (obj.FieldInInt8Pointer != nil && *obj.FieldInInt8Pointer == 34) || (obj.FieldInInt8Pointer != nil && *obj.FieldInInt8Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInInt8Pointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInInt16Pointer != nil && *obj.FieldInInt16Pointer == 12) || (obj.FieldInInt16Pointer != nil && *obj.FieldInInt16Pointer == 34) || (obj.FieldInInt16Pointer != nil && *obj.FieldInInt16Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInInt16Pointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInInt32Pointer != nil && *obj.FieldInInt32Pointer == 12) || (obj.FieldInInt32Pointer != nil && *obj.FieldInInt32Pointer == 34) || (obj.FieldInInt32Pointer != nil && *obj.FieldInInt32Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInInt32Pointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInInt64Pointer != nil && *obj.FieldInInt64Pointer == 12) || (obj.FieldInInt64Pointer != nil && *obj.FieldInInt64Pointer == 34) || (obj.FieldInInt64Pointer != nil && *obj.FieldInInt64Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInInt64Pointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInUintPointer != nil && *obj.FieldInUintPointer == 12) || (obj.FieldInUintPointer != nil && *obj.FieldInUintPointer == 34) || (obj.FieldInUintPointer != nil && *obj.FieldInUintPointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUintPointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInUint8Pointer != nil && *obj.FieldInUint8Pointer == 12) || (obj.FieldInUint8Pointer != nil && *obj.FieldInUint8Pointer == 34) || (obj.FieldInUint8Pointer != nil && *obj.FieldInUint8Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUint8Pointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInUint16Pointer != nil && *obj.FieldInUint16Pointer == 12) || (obj.FieldInUint16Pointer != nil && *obj.FieldInUint16Pointer == 34) || (obj.FieldInUint16Pointer != nil && *obj.FieldInUint16Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUint16Pointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInUint32Pointer != nil && *obj.FieldInUint32Pointer == 12) || (obj.FieldInUint32Pointer != nil && *obj.FieldInUint32Pointer == 34) || (obj.FieldInUint32Pointer != nil && *obj.FieldInUint32Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUint32Pointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInUint64Pointer != nil && *obj.FieldInUint64Pointer == 12) || (obj.FieldInUint64Pointer != nil && *obj.FieldInUint64Pointer == 34) || (obj.FieldInUint64Pointer != nil && *obj.FieldInUint64Pointer == 56)) { +errs = append(errs, types.NewValidationError("FieldInUint64Pointer must be one of '12' '34' '56'")) +} +if !((obj.FieldInFloat32Pointer != nil && *obj.FieldInFloat32Pointer == 11.11) || (obj.FieldInFloat32Pointer != nil && *obj.FieldInFloat32Pointer == 22.22) || (obj.FieldInFloat32Pointer != nil && *obj.FieldInFloat32Pointer == 33.33)) { +errs = append(errs, types.NewValidationError("FieldInFloat32Pointer must be one of '11.11' '22.22' '33.33'")) +} +if !((obj.FieldInFloat64Pointer != nil && *obj.FieldInFloat64Pointer == 11.11) || (obj.FieldInFloat64Pointer != nil && *obj.FieldInFloat64Pointer == 22.22) || (obj.FieldInFloat64Pointer != nil && *obj.FieldInFloat64Pointer == 33.33)) { +errs = append(errs, types.NewValidationError("FieldInFloat64Pointer must be one of '11.11' '22.22' '33.33'")) +} +if !((obj.FieldInBoolPointer != nil && *obj.FieldInBoolPointer == true)) { +errs = append(errs, types.NewValidationError("FieldInBoolPointer must be one of 'true'")) +} +if !(obj.FieldInStringSlicePointer != nil && types.SliceOnlyContains(*obj.FieldInStringSlicePointer, []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldInStringSlicePointer elements must be one of 'ab' 'cd' 'ef'")) +} +if !(obj.FieldInIntSlicePointer != nil && types.SliceOnlyContains(*obj.FieldInIntSlicePointer, []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInIntSlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt8SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInInt8SlicePointer, []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt8SlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt16SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInInt16SlicePointer, []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt16SlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt32SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInInt32SlicePointer, []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt32SlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt64SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInInt64SlicePointer, []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt64SlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUintSlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUintSlicePointer, []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUintSlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint8SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUint8SlicePointer, []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint8SlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint16SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUint16SlicePointer, []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint16SlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint32SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUint32SlicePointer, []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint32SlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint64SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInUint64SlicePointer, []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint64SlicePointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInFloat32SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInFloat32SlicePointer, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32SlicePointer elements must be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldInFloat64SlicePointer != nil && types.SliceOnlyContains(*obj.FieldInFloat64SlicePointer, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64SlicePointer elements must be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldInBoolSlicePointer != nil && types.SliceOnlyContains(*obj.FieldInBoolSlicePointer, []bool{true})) { +errs = append(errs, types.NewValidationError("FieldInBoolSlicePointer elements must be one of 'true'")) +} +if !(obj.FieldInStringArrayPointer != nil && types.SliceOnlyContains(obj.FieldInStringArrayPointer[:], []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldInStringArrayPointer elements must be one of 'ab' 'cd' 'ef'")) +} +if !(obj.FieldInIntArrayPointer != nil && types.SliceOnlyContains(obj.FieldInIntArrayPointer[:], []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInIntArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt8ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInInt8ArrayPointer[:], []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt8ArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt16ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInInt16ArrayPointer[:], []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt16ArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt32ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInInt32ArrayPointer[:], []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt32ArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInInt64ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInInt64ArrayPointer[:], []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInInt64ArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUintArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUintArrayPointer[:], []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUintArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint8ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUint8ArrayPointer[:], []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint8ArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint16ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUint16ArrayPointer[:], []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint16ArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint32ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUint32ArrayPointer[:], []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint32ArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInUint64ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInUint64ArrayPointer[:], []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldInUint64ArrayPointer elements must be one of '12' '34' '56'")) +} +if !(obj.FieldInFloat32ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInFloat32ArrayPointer[:], []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32ArrayPointer elements must be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldInFloat64ArrayPointer != nil && types.SliceOnlyContains(obj.FieldInFloat64ArrayPointer[:], []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64ArrayPointer elements must be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldInBoolArrayPointer != nil && types.SliceOnlyContains(obj.FieldInBoolArrayPointer[:], []bool{true})) { +errs = append(errs, types.NewValidationError("FieldInBoolArrayPointer elements must be one of 'true'")) +} +if !(obj.FieldInStringMapPointer != nil && types.MapOnlyContains(*obj.FieldInStringMapPointer, []string{"a", "b", "c"})) { +errs = append(errs, types.NewValidationError("FieldInStringMapPointer elements must be one of 'a' 'b' 'c'")) +} +if !(obj.FieldInIntMapPointer != nil && types.MapOnlyContains(*obj.FieldInIntMapPointer, []int{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInIntMapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInInt8MapPointer != nil && types.MapOnlyContains(*obj.FieldInInt8MapPointer, []int8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt8MapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInInt16MapPointer != nil && types.MapOnlyContains(*obj.FieldInInt16MapPointer, []int16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt16MapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInInt32MapPointer != nil && types.MapOnlyContains(*obj.FieldInInt32MapPointer, []int32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt32MapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInInt64MapPointer != nil && types.MapOnlyContains(*obj.FieldInInt64MapPointer, []int64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInInt64MapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInUintMapPointer != nil && types.MapOnlyContains(*obj.FieldInUintMapPointer, []uint{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUintMapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInUint8MapPointer != nil && types.MapOnlyContains(*obj.FieldInUint8MapPointer, []uint8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint8MapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInUint16MapPointer != nil && types.MapOnlyContains(*obj.FieldInUint16MapPointer, []uint16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint16MapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInUint32MapPointer != nil && types.MapOnlyContains(*obj.FieldInUint32MapPointer, []uint32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint32MapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInUint64MapPointer != nil && types.MapOnlyContains(*obj.FieldInUint64MapPointer, []uint64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldInUint64MapPointer elements must be one of '1' '2' '3'")) +} +if !(obj.FieldInFloat32MapPointer != nil && types.MapOnlyContains(*obj.FieldInFloat32MapPointer, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat32MapPointer elements must be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldInFloat64MapPointer != nil && types.MapOnlyContains(*obj.FieldInFloat64MapPointer, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldInFloat64MapPointer elements must be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldInBoolMapPointer != nil && types.MapOnlyContains(*obj.FieldInBoolMapPointer, []bool{false})) { +errs = append(errs, types.NewValidationError("FieldInBoolMapPointer elements must be one of 'false'")) +} +return errs +} +`, + }, + { + name: "ninStruct", + structInfo: &analyzer.Struct{ + Struct: parser.Struct{ + PackageName: "main", + StructName: "ninStruct", + Fields: []parser.Field{ + + { + FieldName: "FieldNinStringPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "string", Size: ""}, + Tag: `validate:"nin=ab cd ef"`, + }, + + { + FieldName: "FieldNinIntPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int8", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int16", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int32", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "int64", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUintPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint8Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint8", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint16Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint16", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint32", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "uint64", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinFloat32Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float32", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinFloat64Pointer", + Type: common.FieldType{ComposedType: "*", BaseType: "float64", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinBoolPointer", + Type: common.FieldType{ComposedType: "*", BaseType: "bool", Size: ""}, + Tag: `validate:"nin=true"`, + }, + + { + FieldName: "FieldNinStringSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "string", Size: ""}, + Tag: `validate:"nin=ab cd ef"`, + }, + + { + FieldName: "FieldNinIntSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int8", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int16", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int32", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "int64", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUintSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint8SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint8", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint16SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint16", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint32", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "uint64", Size: ""}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinFloat32SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float32", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinFloat64SlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "float64", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinBoolSlicePointer", + Type: common.FieldType{ComposedType: "*[]", BaseType: "bool", Size: ""}, + Tag: `validate:"nin=true"`, + }, + + { + FieldName: "FieldNinStringArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "string", Size: "3"}, + Tag: `validate:"nin=ab cd ef"`, + }, + + { + FieldName: "FieldNinIntArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt8ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int8", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt16ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int16", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt32ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int32", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinInt64ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "int64", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUintArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint8ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint8", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint16ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint16", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint32ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint32", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinUint64ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "uint64", Size: "3"}, + Tag: `validate:"nin=12 34 56"`, + }, + + { + FieldName: "FieldNinFloat32ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "float32", Size: "3"}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinFloat64ArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "float64", Size: "3"}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinBoolArrayPointer", + Type: common.FieldType{ComposedType: "*[N]", BaseType: "bool", Size: "3"}, + Tag: `validate:"nin=true"`, + }, + + { + FieldName: "FieldNinStringMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "string", Size: ""}, + Tag: `validate:"nin=a b c"`, + }, + + { + FieldName: "FieldNinIntMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinInt8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int8", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinInt16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int16", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinInt32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int32", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinInt64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "int64", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUintMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUint8MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint8", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUint16MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint16", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUint32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint32", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinUint64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "uint64", Size: ""}, + Tag: `validate:"nin=1 2 3"`, + }, + + { + FieldName: "FieldNinFloat32MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float32", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinFloat64MapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "float64", Size: ""}, + Tag: `validate:"nin=11.11 22.22 33.33"`, + }, + + { + FieldName: "FieldNinBoolMapPointer", + Type: common.FieldType{ComposedType: "*map", BaseType: "bool", Size: ""}, + Tag: `validate:"nin=false"`, + }, + }, + }, + FieldsValidations: []analyzer.FieldValidations{ + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=ab cd ef`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=12 34 56`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=true`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=a b c`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=1 2 3`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=11.11 22.22 33.33`)}, + }, + + { + Validations: []*analyzer.Validation{AssertParserValidation(t, `nin=false`)}, + }, + }, + }, + want: `func ninStructValidate(obj *ninStruct) []error { +var errs []error +if !((obj.FieldNinStringPointer != nil && *obj.FieldNinStringPointer != "ab") && (obj.FieldNinStringPointer != nil && *obj.FieldNinStringPointer != "cd") && (obj.FieldNinStringPointer != nil && *obj.FieldNinStringPointer != "ef")) { +errs = append(errs, types.NewValidationError("FieldNinStringPointer must not be one of 'ab' 'cd' 'ef'")) +} +if !((obj.FieldNinIntPointer != nil && *obj.FieldNinIntPointer != 12) && (obj.FieldNinIntPointer != nil && *obj.FieldNinIntPointer != 34) && (obj.FieldNinIntPointer != nil && *obj.FieldNinIntPointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinIntPointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinInt8Pointer != nil && *obj.FieldNinInt8Pointer != 12) && (obj.FieldNinInt8Pointer != nil && *obj.FieldNinInt8Pointer != 34) && (obj.FieldNinInt8Pointer != nil && *obj.FieldNinInt8Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinInt8Pointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinInt16Pointer != nil && *obj.FieldNinInt16Pointer != 12) && (obj.FieldNinInt16Pointer != nil && *obj.FieldNinInt16Pointer != 34) && (obj.FieldNinInt16Pointer != nil && *obj.FieldNinInt16Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinInt16Pointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinInt32Pointer != nil && *obj.FieldNinInt32Pointer != 12) && (obj.FieldNinInt32Pointer != nil && *obj.FieldNinInt32Pointer != 34) && (obj.FieldNinInt32Pointer != nil && *obj.FieldNinInt32Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinInt32Pointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinInt64Pointer != nil && *obj.FieldNinInt64Pointer != 12) && (obj.FieldNinInt64Pointer != nil && *obj.FieldNinInt64Pointer != 34) && (obj.FieldNinInt64Pointer != nil && *obj.FieldNinInt64Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinInt64Pointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinUintPointer != nil && *obj.FieldNinUintPointer != 12) && (obj.FieldNinUintPointer != nil && *obj.FieldNinUintPointer != 34) && (obj.FieldNinUintPointer != nil && *obj.FieldNinUintPointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUintPointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinUint8Pointer != nil && *obj.FieldNinUint8Pointer != 12) && (obj.FieldNinUint8Pointer != nil && *obj.FieldNinUint8Pointer != 34) && (obj.FieldNinUint8Pointer != nil && *obj.FieldNinUint8Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUint8Pointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinUint16Pointer != nil && *obj.FieldNinUint16Pointer != 12) && (obj.FieldNinUint16Pointer != nil && *obj.FieldNinUint16Pointer != 34) && (obj.FieldNinUint16Pointer != nil && *obj.FieldNinUint16Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUint16Pointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinUint32Pointer != nil && *obj.FieldNinUint32Pointer != 12) && (obj.FieldNinUint32Pointer != nil && *obj.FieldNinUint32Pointer != 34) && (obj.FieldNinUint32Pointer != nil && *obj.FieldNinUint32Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUint32Pointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinUint64Pointer != nil && *obj.FieldNinUint64Pointer != 12) && (obj.FieldNinUint64Pointer != nil && *obj.FieldNinUint64Pointer != 34) && (obj.FieldNinUint64Pointer != nil && *obj.FieldNinUint64Pointer != 56)) { +errs = append(errs, types.NewValidationError("FieldNinUint64Pointer must not be one of '12' '34' '56'")) +} +if !((obj.FieldNinFloat32Pointer != nil && *obj.FieldNinFloat32Pointer != 11.11) && (obj.FieldNinFloat32Pointer != nil && *obj.FieldNinFloat32Pointer != 22.22) && (obj.FieldNinFloat32Pointer != nil && *obj.FieldNinFloat32Pointer != 33.33)) { +errs = append(errs, types.NewValidationError("FieldNinFloat32Pointer must not be one of '11.11' '22.22' '33.33'")) +} +if !((obj.FieldNinFloat64Pointer != nil && *obj.FieldNinFloat64Pointer != 11.11) && (obj.FieldNinFloat64Pointer != nil && *obj.FieldNinFloat64Pointer != 22.22) && (obj.FieldNinFloat64Pointer != nil && *obj.FieldNinFloat64Pointer != 33.33)) { +errs = append(errs, types.NewValidationError("FieldNinFloat64Pointer must not be one of '11.11' '22.22' '33.33'")) +} +if !((obj.FieldNinBoolPointer != nil && *obj.FieldNinBoolPointer != true)) { +errs = append(errs, types.NewValidationError("FieldNinBoolPointer must not be one of 'true'")) +} +if !(obj.FieldNinStringSlicePointer != nil && types.SliceNotContains(*obj.FieldNinStringSlicePointer, []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldNinStringSlicePointer elements must not be one of 'ab' 'cd' 'ef'")) +} +if !(obj.FieldNinIntSlicePointer != nil && types.SliceNotContains(*obj.FieldNinIntSlicePointer, []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinIntSlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt8SlicePointer != nil && types.SliceNotContains(*obj.FieldNinInt8SlicePointer, []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt8SlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt16SlicePointer != nil && types.SliceNotContains(*obj.FieldNinInt16SlicePointer, []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt16SlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt32SlicePointer != nil && types.SliceNotContains(*obj.FieldNinInt32SlicePointer, []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt32SlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt64SlicePointer != nil && types.SliceNotContains(*obj.FieldNinInt64SlicePointer, []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt64SlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUintSlicePointer != nil && types.SliceNotContains(*obj.FieldNinUintSlicePointer, []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUintSlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint8SlicePointer != nil && types.SliceNotContains(*obj.FieldNinUint8SlicePointer, []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint8SlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint16SlicePointer != nil && types.SliceNotContains(*obj.FieldNinUint16SlicePointer, []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint16SlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint32SlicePointer != nil && types.SliceNotContains(*obj.FieldNinUint32SlicePointer, []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint32SlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint64SlicePointer != nil && types.SliceNotContains(*obj.FieldNinUint64SlicePointer, []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint64SlicePointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinFloat32SlicePointer != nil && types.SliceNotContains(*obj.FieldNinFloat32SlicePointer, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32SlicePointer elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldNinFloat64SlicePointer != nil && types.SliceNotContains(*obj.FieldNinFloat64SlicePointer, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64SlicePointer elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldNinBoolSlicePointer != nil && types.SliceNotContains(*obj.FieldNinBoolSlicePointer, []bool{true})) { +errs = append(errs, types.NewValidationError("FieldNinBoolSlicePointer elements must not be one of 'true'")) +} +if !(obj.FieldNinStringArrayPointer != nil && types.SliceNotContains(obj.FieldNinStringArrayPointer[:], []string{"ab", "cd", "ef"})) { +errs = append(errs, types.NewValidationError("FieldNinStringArrayPointer elements must not be one of 'ab' 'cd' 'ef'")) +} +if !(obj.FieldNinIntArrayPointer != nil && types.SliceNotContains(obj.FieldNinIntArrayPointer[:], []int{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinIntArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt8ArrayPointer != nil && types.SliceNotContains(obj.FieldNinInt8ArrayPointer[:], []int8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt8ArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt16ArrayPointer != nil && types.SliceNotContains(obj.FieldNinInt16ArrayPointer[:], []int16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt16ArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt32ArrayPointer != nil && types.SliceNotContains(obj.FieldNinInt32ArrayPointer[:], []int32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt32ArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinInt64ArrayPointer != nil && types.SliceNotContains(obj.FieldNinInt64ArrayPointer[:], []int64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinInt64ArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUintArrayPointer != nil && types.SliceNotContains(obj.FieldNinUintArrayPointer[:], []uint{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUintArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint8ArrayPointer != nil && types.SliceNotContains(obj.FieldNinUint8ArrayPointer[:], []uint8{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint8ArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint16ArrayPointer != nil && types.SliceNotContains(obj.FieldNinUint16ArrayPointer[:], []uint16{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint16ArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint32ArrayPointer != nil && types.SliceNotContains(obj.FieldNinUint32ArrayPointer[:], []uint32{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint32ArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinUint64ArrayPointer != nil && types.SliceNotContains(obj.FieldNinUint64ArrayPointer[:], []uint64{12, 34, 56})) { +errs = append(errs, types.NewValidationError("FieldNinUint64ArrayPointer elements must not be one of '12' '34' '56'")) +} +if !(obj.FieldNinFloat32ArrayPointer != nil && types.SliceNotContains(obj.FieldNinFloat32ArrayPointer[:], []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32ArrayPointer elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldNinFloat64ArrayPointer != nil && types.SliceNotContains(obj.FieldNinFloat64ArrayPointer[:], []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64ArrayPointer elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldNinBoolArrayPointer != nil && types.SliceNotContains(obj.FieldNinBoolArrayPointer[:], []bool{true})) { +errs = append(errs, types.NewValidationError("FieldNinBoolArrayPointer elements must not be one of 'true'")) +} +if !(obj.FieldNinStringMapPointer != nil && types.MapNotContains(*obj.FieldNinStringMapPointer, []string{"a", "b", "c"})) { +errs = append(errs, types.NewValidationError("FieldNinStringMapPointer elements must not be one of 'a' 'b' 'c'")) +} +if !(obj.FieldNinIntMapPointer != nil && types.MapNotContains(*obj.FieldNinIntMapPointer, []int{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinIntMapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinInt8MapPointer != nil && types.MapNotContains(*obj.FieldNinInt8MapPointer, []int8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt8MapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinInt16MapPointer != nil && types.MapNotContains(*obj.FieldNinInt16MapPointer, []int16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt16MapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinInt32MapPointer != nil && types.MapNotContains(*obj.FieldNinInt32MapPointer, []int32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt32MapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinInt64MapPointer != nil && types.MapNotContains(*obj.FieldNinInt64MapPointer, []int64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinInt64MapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinUintMapPointer != nil && types.MapNotContains(*obj.FieldNinUintMapPointer, []uint{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUintMapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinUint8MapPointer != nil && types.MapNotContains(*obj.FieldNinUint8MapPointer, []uint8{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint8MapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinUint16MapPointer != nil && types.MapNotContains(*obj.FieldNinUint16MapPointer, []uint16{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint16MapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinUint32MapPointer != nil && types.MapNotContains(*obj.FieldNinUint32MapPointer, []uint32{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint32MapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinUint64MapPointer != nil && types.MapNotContains(*obj.FieldNinUint64MapPointer, []uint64{1, 2, 3})) { +errs = append(errs, types.NewValidationError("FieldNinUint64MapPointer elements must not be one of '1' '2' '3'")) +} +if !(obj.FieldNinFloat32MapPointer != nil && types.MapNotContains(*obj.FieldNinFloat32MapPointer, []float32{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat32MapPointer elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldNinFloat64MapPointer != nil && types.MapNotContains(*obj.FieldNinFloat64MapPointer, []float64{11.11, 22.22, 33.33})) { +errs = append(errs, types.NewValidationError("FieldNinFloat64MapPointer elements must not be one of '11.11' '22.22' '33.33'")) +} +if !(obj.FieldNinBoolMapPointer != nil && types.MapNotContains(*obj.FieldNinBoolMapPointer, []bool{false})) { +errs = append(errs, types.NewValidationError("FieldNinBoolMapPointer elements must not be one of 'false'")) +} +return errs +} +`, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + gv := GenValidations{ + Struct: tt.structInfo, + } + got, err := gv.BuildFuncValidatorCode() + if err != nil { + t.Errorf("FileValidator.GenerateValidator() error = %v, wantErr %v", err, nil) + return + } + if got != tt.want { + t.Errorf("FileValidator.GenerateValidator() = %v, want %v", got, tt.want) + dmp := diffmatchpatch.New() + diffs := dmp.DiffMain(tt.want, got, false) + if len(diffs) > 1 { + t.Errorf("FileValidator.GenerateValidator() diff = \n%v", dmp.DiffPrettyText(diffs)) + } + } + }) + } +} From e0325e64cd1f1d432fae1ec4ca34e03de67c405c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Tue, 28 Oct 2025 10:44:54 -0300 Subject: [PATCH 14/31] chore: remove use slice[n] to avoid panic --- testgen/generate_function_code_tests.go | 29 ++++++++++++++----------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/testgen/generate_function_code_tests.go b/testgen/generate_function_code_tests.go index d7c45f6..e1221b0 100644 --- a/testgen/generate_function_code_tests.go +++ b/testgen/generate_function_code_tests.go @@ -52,15 +52,15 @@ func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { } for _, typeValidation := range typesValidation { - testCases.Tests = append(testCases.Tests, FunctionCodeTestCase{ + newTest := FunctionCodeTestCase{ TestName: typeValidation.tag + "Struct", StructName: typeValidation.tag + "Struct", - }) - currentTest := &testCases.Tests[len(testCases.Tests)-1] + } + structInfo := &analyzer.Struct{ Struct: parser.Struct{ PackageName: "main", - StructName: currentTest.StructName, + StructName: newTest.StructName, }, } @@ -92,7 +92,7 @@ func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { log.Fatalf("failed to parse validation %q: %v", validation, err) } - currentTest.Fields = append(currentTest.Fields, FunctionCodeTestField{ + newTest.Fields = append(newTest.Fields, FunctionCodeTestField{ Name: fieldName, Type: fieldType, Tag: validation, @@ -107,17 +107,20 @@ func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { Validations: []*analyzer.Validation{parsedValidation}, }) } + } - gv := codegenerator.GenValidations{ - Struct: structInfo, - } + gv := codegenerator.GenValidations{ + Struct: structInfo, + } - got, err := gv.BuildFuncValidatorCode() - if err != nil { - log.Fatalf("failed to build function validator code for struct %q: %v", currentTest.StructName, err) - } - currentTest.ExpectedCode = got + expectedCode, err := gv.BuildFuncValidatorCode() + if err != nil { + log.Fatalf("failed to build function validator code for struct %q: %v", newTest.StructName, err) } + + newTest.ExpectedCode = expectedCode + + testCases.Tests = append(testCases.Tests, newTest) } if err := testCases.GenerateFile(tpl, dest); err != nil { From 4f9fa1257cd7ebaaac8f6424e5db122e11d5eb42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Tue, 28 Oct 2025 10:53:19 -0300 Subject: [PATCH 15/31] chore: better way to chain calls in the makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index dc3ff54..7702131 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ build: clean testgen: @echo "Generating tests" - cd testgen/ && rm -f generated_*.go; go run *.go && mv generated_endtoend_*tests.go ../tests/endtoend/ && mv generated_validation_*_test.go ../internal/codegenerator/ && mv generated_function_code_*_test.go ../internal/codegenerator/ + cd testgen/ && rm -f generated_*.go && go run *.go && mv generated_endtoend_*tests.go ../tests/endtoend/ && mv generated_validation_*_test.go ../internal/codegenerator/ && mv generated_function_code_*_test.go ../internal/codegenerator/ endtoendtests: build @echo "Running endtoend tests" From 427754da1d5a3a21cb96672a41a6b1adf0ef1139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Wed, 29 Oct 2025 10:36:39 -0300 Subject: [PATCH 16/31] chore: use bitfield to exclude tests to be generated --- testgen/generate_function_code_tests.go | 11 +++-------- testgen/generate_validation_code_tests.go | 11 +++-------- testgen/generate_validation_types_tests.go | 12 ++++-------- 3 files changed, 10 insertions(+), 24 deletions(-) diff --git a/testgen/generate_function_code_tests.go b/testgen/generate_function_code_tests.go index e1221b0..dfb6df5 100644 --- a/testgen/generate_function_code_tests.go +++ b/testgen/generate_function_code_tests.go @@ -65,14 +65,9 @@ func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { } for _, toGenerate := range typeValidation.testCases { - // Default ("") gen no pointer and pointer test. - if toGenerate.generateFor != "" { - if toGenerate.generateFor == "pointer" && !pointer { - continue - } - if toGenerate.generateFor == "nopointer" && pointer { - continue - } + if toGenerate.excludeIf&noPointer != 0 && !pointer { + log.Printf("Skipping no pointer: tag %s type %s\n", typeValidation.tag, toGenerate.typeClass) + continue } normalizedType := toGenerate.typeClass diff --git a/testgen/generate_validation_code_tests.go b/testgen/generate_validation_code_tests.go index 44531a3..0e176b0 100644 --- a/testgen/generate_validation_code_tests.go +++ b/testgen/generate_validation_code_tests.go @@ -47,14 +47,9 @@ func generateValidationCodeTestsFile(tpl, dest string, pointer bool) { for _, typeValidation := range typesValidation { for _, toGenerate := range typeValidation.testCases { - // Default ("") gen no pointer and pointer test. - if toGenerate.generateFor != "" { - if toGenerate.generateFor == "pointer" && !pointer { - continue - } - if toGenerate.generateFor == "nopointer" && pointer { - continue - } + if toGenerate.excludeIf&noPointer != 0 && !pointer { + log.Printf("Skipping no pointer: tag %s type %s\n", typeValidation.tag, toGenerate.typeClass) + continue } normalizedType := toGenerate.typeClass diff --git a/testgen/generate_validation_types_tests.go b/testgen/generate_validation_types_tests.go index f848725..1619d53 100644 --- a/testgen/generate_validation_types_tests.go +++ b/testgen/generate_validation_types_tests.go @@ -52,15 +52,11 @@ func generateValidationTypesTestsFile(tpl, dest string, pointer bool) { StructName: structName, }) for _, toGenerate := range testCase.testCases { - // Default ("") gen no pointer and pointer test. - if toGenerate.generateFor != "" { - if toGenerate.generateFor == "pointer" && !pointer { - continue - } - if toGenerate.generateFor == "nopointer" && pointer { - continue - } + if toGenerate.excludeIf&noPointer != 0 && !pointer { + log.Printf("Skipping no pointer: tag %s type %s\n", testCase.tag, toGenerate.typeClass) + continue } + normalizedType := toGenerate.typeClass if pointer { normalizedType = "*" + normalizedType From b205a3a3b8540e3d2f873d770d5a23f8f8d58253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Wed, 29 Oct 2025 10:38:36 -0300 Subject: [PATCH 17/31] chore: add govalidator tag to generated cmp perf tests --- testgen/validations.go | 59 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 19 deletions(-) diff --git a/testgen/validations.go b/testgen/validations.go index c0c5661..babf8c6 100644 --- a/testgen/validations.go +++ b/testgen/validations.go @@ -2,13 +2,20 @@ package main import "github.com/opencodeco/validgen/internal/common" +type excludeIf uint32 + +const ( + cmpBenchTests excludeIf = 1 << iota + noPointer +) + type typeValidation struct { typeClass string validation string validCase string invalidCase string errorMessage string - generateFor string + excludeIf excludeIf } var typesValidation = []struct { @@ -21,7 +28,7 @@ var typesValidation = []struct { // email operations { tag: "email", - validatorTag: ``, + validatorTag: `email`, isFieldValidation: false, argsCount: common.ZeroValue, testCases: []typeValidation{ @@ -39,7 +46,7 @@ var typesValidation = []struct { // required operations { tag: "required", - validatorTag: ``, + validatorTag: `required`, isFieldValidation: false, argsCount: common.ZeroValue, testCases: []typeValidation{ @@ -110,7 +117,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{"abcde"}`, invalidCase: `--`, errorMessage: `{{.FieldName}} must not be empty`, - generateFor: "pointer", + excludeIf: noPointer, }, { typeClass: `[N]`, @@ -118,7 +125,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{32}`, invalidCase: `--`, errorMessage: `{{.FieldName}} must not be empty`, - generateFor: "pointer", + excludeIf: noPointer, }, { typeClass: `[N]`, @@ -126,7 +133,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{12.34}`, invalidCase: `--`, errorMessage: `{{.FieldName}} must not be empty`, - generateFor: "pointer", + excludeIf: noPointer, }, { typeClass: `[N]`, @@ -134,7 +141,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{true}`, invalidCase: `--`, errorMessage: `{{.FieldName}} must not be empty`, - generateFor: "pointer", + excludeIf: noPointer, }, // required: "map[]", "map[]", "map[]", "map[]" @@ -172,7 +179,7 @@ var typesValidation = []struct { // eq operations { tag: "eq", - validatorTag: ``, + validatorTag: `eq`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -211,7 +218,7 @@ var typesValidation = []struct { // neq operations { tag: "neq", - validatorTag: ``, + validatorTag: `ne`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -250,7 +257,7 @@ var typesValidation = []struct { // gt operations { tag: "gt", - validatorTag: ``, + validatorTag: `gt`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -275,7 +282,7 @@ var typesValidation = []struct { // gte operations { tag: "gte", - validatorTag: ``, + validatorTag: `gte`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -300,7 +307,7 @@ var typesValidation = []struct { // lt operations { tag: "lt", - validatorTag: ``, + validatorTag: `lt`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -325,7 +332,7 @@ var typesValidation = []struct { // lte operations { tag: "lte", - validatorTag: ``, + validatorTag: `lte`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -350,7 +357,7 @@ var typesValidation = []struct { // min operations { tag: "min", - validatorTag: ``, + validatorTag: `min`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -428,7 +435,7 @@ var typesValidation = []struct { // max operations { tag: "max", - validatorTag: ``, + validatorTag: `max`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -506,7 +513,7 @@ var typesValidation = []struct { // eq_ignore_case operations { tag: "eq_ignore_case", - validatorTag: ``, + validatorTag: `eq_ignore_case`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -524,7 +531,7 @@ var typesValidation = []struct { // neq_ignore_case operations { tag: "neq_ignore_case", - validatorTag: ``, + validatorTag: `ne_ignore_case`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -542,7 +549,7 @@ var typesValidation = []struct { // len operations { tag: "len", - validatorTag: ``, + validatorTag: `len`, isFieldValidation: false, argsCount: common.OneValue, testCases: []typeValidation{ @@ -620,7 +627,7 @@ var typesValidation = []struct { // in operations { tag: "in", - validatorTag: ``, + validatorTag: `oneof`, isFieldValidation: false, argsCount: common.ManyValues, testCases: []typeValidation{ @@ -645,6 +652,7 @@ var typesValidation = []struct { validCase: `22.22`, invalidCase: `44.44`, errorMessage: `{{.FieldName}} must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: ``, @@ -652,6 +660,7 @@ var typesValidation = []struct { validCase: `true`, invalidCase: `false`, errorMessage: `{{.FieldName}} must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, // in: "[]", "[]", "[]", "[]" @@ -661,6 +670,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{"ab", "ef"}`, invalidCase: `{{.BasicType}}{"ab", "gh", "ef"}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: `[]`, @@ -668,6 +678,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{12, 56}`, invalidCase: `{{.BasicType}}{12, 78, 56}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: `[]`, @@ -675,6 +686,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{11.11, 22.22}`, invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: `[]`, @@ -682,6 +694,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{true, true}`, invalidCase: `{{.BasicType}}{true, false, true}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, // in: "[]", "[]", "[]", "[]" @@ -691,6 +704,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{"ab", "ef", "ab"}`, invalidCase: `{{.BasicType}}{"ab", "gh", "ef"}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: `[N]`, @@ -698,6 +712,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{12, 56, 12}`, invalidCase: `{{.BasicType}}{12, 78, 56}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: `[N]`, @@ -705,6 +720,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{11.11, 22.22, 11.11}`, invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: `[N]`, @@ -712,6 +728,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{true, true, true}`, invalidCase: `{{.BasicType}}{true, false, true}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, // in: "map[]", "map[]", "map[]", "map[]" @@ -721,6 +738,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{"a": "1", "b": "2", "c": "3"}`, invalidCase: `{{.BasicType}}{"a": "1", "d": "9", "c": "3"}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: `map[]`, @@ -728,6 +746,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{1: 65, 2: 67, 3: 68}`, invalidCase: `{{.BasicType}}{1: 65, 4: 69, 3: 68}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: `map[]`, @@ -735,6 +754,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{11.11: 11.11, 22.22: 22.22, 33.33: 33.33}`, invalidCase: `{{.BasicType}}{11.11: 11.11, 44.44: 44.44, 33.33: 33.33}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, { typeClass: `map[]`, @@ -742,6 +762,7 @@ var typesValidation = []struct { validCase: `{{.BasicType}}{false: false}`, invalidCase: `{{.BasicType}}{true: true, false: false}`, errorMessage: `{{.FieldName}} elements must be one of {{.Targets}}`, + excludeIf: cmpBenchTests, }, }, }, From 8a8c8f8d27410297d80ab470da412abfb0ce1f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Wed, 29 Oct 2025 10:40:25 -0300 Subject: [PATCH 18/31] feat: generate perf cmp tests in testgen --- Makefile | 4 +- testgen/cmp_perf_no_pointer_tests.tpl | 48 ++++++++++ testgen/cmp_perf_pointer_tests.tpl | 52 +++++++++++ testgen/generate_cmp_perf_tests.go | 124 ++++++++++++++++++++++++++ testgen/generate_tests.go | 1 + 5 files changed, 227 insertions(+), 2 deletions(-) create mode 100644 testgen/cmp_perf_no_pointer_tests.tpl create mode 100644 testgen/cmp_perf_pointer_tests.tpl create mode 100644 testgen/generate_cmp_perf_tests.go diff --git a/Makefile b/Makefile index 7702131..48b817d 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ build: clean testgen: @echo "Generating tests" - cd testgen/ && rm -f generated_*.go && go run *.go && mv generated_endtoend_*tests.go ../tests/endtoend/ && mv generated_validation_*_test.go ../internal/codegenerator/ && mv generated_function_code_*_test.go ../internal/codegenerator/ + cd testgen/ && rm -f generated_*.go && go run *.go && mv generated_endtoend_*tests.go ../tests/endtoend/ && mv generated_validation_*_test.go ../internal/codegenerator/ && mv generated_function_code_*_test.go ../internal/codegenerator/ && mv generated_cmp_perf_*.go ../tests/cmpbenchtests/generated_tests/ endtoendtests: build @echo "Running endtoend tests" @@ -41,7 +41,7 @@ endtoendtests: build cmpbenchtests: build @echo "Running cmp bench tests" - rm -f tests/cmpbenchtests/generated_tests/* + rm -f tests/cmpbenchtests/generated_tests/valid*.go && rm -f tests/cmpbenchtests/generated_tests/types.go cd tests/cmpbenchtests; go run . $(VALIDGEN_BIN) tests/cmpbenchtests/generated_tests go clean -testcache diff --git a/testgen/cmp_perf_no_pointer_tests.tpl b/testgen/cmp_perf_no_pointer_tests.tpl new file mode 100644 index 0000000..49a3d95 --- /dev/null +++ b/testgen/cmp_perf_no_pointer_tests.tpl @@ -0,0 +1,48 @@ +// Code generated by TestGen. DO NOT EDIT. + +package benchtests + +import ( + "testing" + + "github.com/go-playground/validator/v10" +) + +{{range .Tests}} +type ValidGen{{.TestName}}Struct struct { + Field {{.FieldType}} `valid:"{{.ValidGenTag}}"` +} + +type Validator{{.TestName}}Struct struct { + Field {{.FieldType}} `validate:"{{.ValidatorTag}}"` +} +{{end}} + +{{range .Tests}} +func BenchmarkValidGen{{.TestName}}(b *testing.B) { + data := &ValidGen{{.TestName}}Struct{ + Field: {{.ValidInput}}, + } + + for b.Loop() { + if err := ValidGen{{.TestName}}StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidator{{.TestName}}(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &Validator{{.TestName}}Struct{ + Field: {{.ValidInput}}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} +{{end}} \ No newline at end of file diff --git a/testgen/cmp_perf_pointer_tests.tpl b/testgen/cmp_perf_pointer_tests.tpl new file mode 100644 index 0000000..cae5284 --- /dev/null +++ b/testgen/cmp_perf_pointer_tests.tpl @@ -0,0 +1,52 @@ +// Code generated by TestGen. DO NOT EDIT. + +package benchtests + +import ( + "testing" + + "github.com/go-playground/validator/v10" +) + +{{range .Tests}} +type ValidGen{{.TestName}}Struct struct { + Field {{.FieldType}} `valid:"{{.ValidGenTag}}"` +} + +type Validator{{.TestName}}Struct struct { + Field {{.FieldType}} `validate:"{{.ValidatorTag}}"` +} +{{end}} + +{{range .Tests}} +func BenchmarkValidGen{{.TestName}}(b *testing.B) { + var validInput {{.BasicType}} = {{.ValidInput}} + data := &ValidGen{{.TestName}}Struct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGen{{.TestName}}StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidator{{.TestName}}(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput {{.BasicType}} = {{.ValidInput}} + + data := &Validator{{.TestName}}Struct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} +{{end}} \ No newline at end of file diff --git a/testgen/generate_cmp_perf_tests.go b/testgen/generate_cmp_perf_tests.go new file mode 100644 index 0000000..f02b772 --- /dev/null +++ b/testgen/generate_cmp_perf_tests.go @@ -0,0 +1,124 @@ +package main + +import ( + "bytes" + "fmt" + "go/format" + "log" + "os" + "strings" + "text/template" + + "github.com/opencodeco/validgen/internal/common" + "golang.org/x/text/cases" + "golang.org/x/text/language" +) + +type CmpBenchTests struct { + Tests []CmpBenchTest +} + +type CmpBenchTest struct { + TestName string + FieldType string + BasicType string + ValidGenTag string + ValidatorTag string + ValidInput string +} + +func generateComparativePerformanceTests() { + generateComparativePerformanceTest("cmp_perf_no_pointer_tests.tpl", "generated_cmp_perf_no_pointer_test.go", false) + generateComparativePerformanceTest("cmp_perf_pointer_tests.tpl", "generated_cmp_perf_pointer_test.go", true) +} + +func generateComparativePerformanceTest(tpl, dest string, pointer bool) { + log.Printf("Generating comparative performance tests file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) + + benchTests := CmpBenchTests{} + + for _, typeVal := range typesValidation { + if typeVal.validatorTag == "" { + log.Printf("Skipping tag %s: go-validator tag not defined\n", typeVal.tag) + continue + } + + for _, testCase := range typeVal.testCases { + if testCase.excludeIf&cmpBenchTests != 0 { + log.Printf("Skipping test: tag %s type %s\n", typeVal.tag, testCase.typeClass) + continue + } + if testCase.excludeIf&noPointer != 0 && !pointer { + log.Printf("Skipping no pointer: tag %s type %s\n", typeVal.tag, testCase.typeClass) + continue + } + + normalizedType := testCase.typeClass + if pointer { + normalizedType = "*" + normalizedType + } + + fTypes := common.HelperFromNormalizedToBasicTypes(normalizedType) + sNames := common.HelperFromNormalizedToStringNames(normalizedType) + + for i := range fTypes { + validGenTag := typeVal.tag + if typeVal.argsCount != common.ZeroValue { + validGenTag += "=" + testCase.validation + } + goValidatorTag := typeVal.validatorTag + if typeVal.argsCount != common.ZeroValue { + goValidatorTag += "=" + testCase.validation + } + testName := cases.Title(language.Und).String(typeVal.tag) + sNames[i] + + basicType, _ := strings.CutPrefix(fTypes[i], "*") + + benchTests.Tests = append(benchTests.Tests, CmpBenchTest{ + TestName: testName, + FieldType: fTypes[i], + BasicType: basicType, + ValidGenTag: validGenTag, + ValidatorTag: goValidatorTag, + ValidInput: strings.ReplaceAll(testCase.validCase, "{{.BasicType}}", basicType), + }) + } + } + } + + log.Printf("%d test cases were generated\n", len(benchTests.Tests)) + + if err := benchTests.GenerateFile(tpl, dest); err != nil { + log.Fatalf("error generating comparative performance tests file %s", err) + } + + log.Println("Generating done") +} + +func (cbt *CmpBenchTests) GenerateFile(tplFile, output string) error { + tpl, err := os.ReadFile(tplFile) + if err != nil { + return fmt.Errorf("error reading %s: %s", tplFile, err) + } + + tmpl, err := template.New("BenchTest").Parse(string(tpl)) + if err != nil { + return fmt.Errorf("error parsing template %s: %s", tplFile, err) + } + + code := new(bytes.Buffer) + if err := tmpl.Execute(code, cbt); err != nil { + return err + } + + formattedCode, err := format.Source(code.Bytes()) + if err != nil { + return err + } + + if err := os.WriteFile(output, formattedCode, 0644); err != nil { + return err + } + + return nil +} diff --git a/testgen/generate_tests.go b/testgen/generate_tests.go index 1b06a69..09d9c0f 100644 --- a/testgen/generate_tests.go +++ b/testgen/generate_tests.go @@ -10,6 +10,7 @@ func main() { generateValidationTypesEndToEndTests() generateValidationCodeUnitTests() generateFunctionCodeUnitTests() + generateComparativePerformanceTests() fmt.Println("Generating done") } From c09649e8c1624899db260444c21fbeda92225191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Wed, 29 Oct 2025 10:42:03 -0300 Subject: [PATCH 19/31] chore: add generated perf tests --- .../generated_cmp_perf_no_pointer_test.go | 7674 ++++++++++++++ .../generated_cmp_perf_pointer_test.go | 9096 +++++++++++++++++ .../generated_tests/validator__.go | 3164 ++++++ 3 files changed, 19934 insertions(+) create mode 100644 tests/cmpbenchtests/generated_tests/generated_cmp_perf_no_pointer_test.go create mode 100644 tests/cmpbenchtests/generated_tests/generated_cmp_perf_pointer_test.go diff --git a/tests/cmpbenchtests/generated_tests/generated_cmp_perf_no_pointer_test.go b/tests/cmpbenchtests/generated_tests/generated_cmp_perf_no_pointer_test.go new file mode 100644 index 0000000..bb96ee7 --- /dev/null +++ b/tests/cmpbenchtests/generated_tests/generated_cmp_perf_no_pointer_test.go @@ -0,0 +1,7674 @@ +// Code generated by TestGen. DO NOT EDIT. + +package benchtests + +import ( + "testing" + + "github.com/go-playground/validator/v10" +) + +type ValidGenEmailStringStruct struct { + Field string `valid:"email"` +} + +type ValidatorEmailStringStruct struct { + Field string `validate:"email"` +} + +type ValidGenRequiredStringStruct struct { + Field string `valid:"required"` +} + +type ValidatorRequiredStringStruct struct { + Field string `validate:"required"` +} + +type ValidGenRequiredIntStruct struct { + Field int `valid:"required"` +} + +type ValidatorRequiredIntStruct struct { + Field int `validate:"required"` +} + +type ValidGenRequiredInt8Struct struct { + Field int8 `valid:"required"` +} + +type ValidatorRequiredInt8Struct struct { + Field int8 `validate:"required"` +} + +type ValidGenRequiredInt16Struct struct { + Field int16 `valid:"required"` +} + +type ValidatorRequiredInt16Struct struct { + Field int16 `validate:"required"` +} + +type ValidGenRequiredInt32Struct struct { + Field int32 `valid:"required"` +} + +type ValidatorRequiredInt32Struct struct { + Field int32 `validate:"required"` +} + +type ValidGenRequiredInt64Struct struct { + Field int64 `valid:"required"` +} + +type ValidatorRequiredInt64Struct struct { + Field int64 `validate:"required"` +} + +type ValidGenRequiredUintStruct struct { + Field uint `valid:"required"` +} + +type ValidatorRequiredUintStruct struct { + Field uint `validate:"required"` +} + +type ValidGenRequiredUint8Struct struct { + Field uint8 `valid:"required"` +} + +type ValidatorRequiredUint8Struct struct { + Field uint8 `validate:"required"` +} + +type ValidGenRequiredUint16Struct struct { + Field uint16 `valid:"required"` +} + +type ValidatorRequiredUint16Struct struct { + Field uint16 `validate:"required"` +} + +type ValidGenRequiredUint32Struct struct { + Field uint32 `valid:"required"` +} + +type ValidatorRequiredUint32Struct struct { + Field uint32 `validate:"required"` +} + +type ValidGenRequiredUint64Struct struct { + Field uint64 `valid:"required"` +} + +type ValidatorRequiredUint64Struct struct { + Field uint64 `validate:"required"` +} + +type ValidGenRequiredFloat32Struct struct { + Field float32 `valid:"required"` +} + +type ValidatorRequiredFloat32Struct struct { + Field float32 `validate:"required"` +} + +type ValidGenRequiredFloat64Struct struct { + Field float64 `valid:"required"` +} + +type ValidatorRequiredFloat64Struct struct { + Field float64 `validate:"required"` +} + +type ValidGenRequiredBoolStruct struct { + Field bool `valid:"required"` +} + +type ValidatorRequiredBoolStruct struct { + Field bool `validate:"required"` +} + +type ValidGenRequiredStringSliceStruct struct { + Field []string `valid:"required"` +} + +type ValidatorRequiredStringSliceStruct struct { + Field []string `validate:"required"` +} + +type ValidGenRequiredIntSliceStruct struct { + Field []int `valid:"required"` +} + +type ValidatorRequiredIntSliceStruct struct { + Field []int `validate:"required"` +} + +type ValidGenRequiredInt8SliceStruct struct { + Field []int8 `valid:"required"` +} + +type ValidatorRequiredInt8SliceStruct struct { + Field []int8 `validate:"required"` +} + +type ValidGenRequiredInt16SliceStruct struct { + Field []int16 `valid:"required"` +} + +type ValidatorRequiredInt16SliceStruct struct { + Field []int16 `validate:"required"` +} + +type ValidGenRequiredInt32SliceStruct struct { + Field []int32 `valid:"required"` +} + +type ValidatorRequiredInt32SliceStruct struct { + Field []int32 `validate:"required"` +} + +type ValidGenRequiredInt64SliceStruct struct { + Field []int64 `valid:"required"` +} + +type ValidatorRequiredInt64SliceStruct struct { + Field []int64 `validate:"required"` +} + +type ValidGenRequiredUintSliceStruct struct { + Field []uint `valid:"required"` +} + +type ValidatorRequiredUintSliceStruct struct { + Field []uint `validate:"required"` +} + +type ValidGenRequiredUint8SliceStruct struct { + Field []uint8 `valid:"required"` +} + +type ValidatorRequiredUint8SliceStruct struct { + Field []uint8 `validate:"required"` +} + +type ValidGenRequiredUint16SliceStruct struct { + Field []uint16 `valid:"required"` +} + +type ValidatorRequiredUint16SliceStruct struct { + Field []uint16 `validate:"required"` +} + +type ValidGenRequiredUint32SliceStruct struct { + Field []uint32 `valid:"required"` +} + +type ValidatorRequiredUint32SliceStruct struct { + Field []uint32 `validate:"required"` +} + +type ValidGenRequiredUint64SliceStruct struct { + Field []uint64 `valid:"required"` +} + +type ValidatorRequiredUint64SliceStruct struct { + Field []uint64 `validate:"required"` +} + +type ValidGenRequiredFloat32SliceStruct struct { + Field []float32 `valid:"required"` +} + +type ValidatorRequiredFloat32SliceStruct struct { + Field []float32 `validate:"required"` +} + +type ValidGenRequiredFloat64SliceStruct struct { + Field []float64 `valid:"required"` +} + +type ValidatorRequiredFloat64SliceStruct struct { + Field []float64 `validate:"required"` +} + +type ValidGenRequiredBoolSliceStruct struct { + Field []bool `valid:"required"` +} + +type ValidatorRequiredBoolSliceStruct struct { + Field []bool `validate:"required"` +} + +type ValidGenRequiredStringMapStruct struct { + Field map[string]string `valid:"required"` +} + +type ValidatorRequiredStringMapStruct struct { + Field map[string]string `validate:"required"` +} + +type ValidGenRequiredIntMapStruct struct { + Field map[int]int `valid:"required"` +} + +type ValidatorRequiredIntMapStruct struct { + Field map[int]int `validate:"required"` +} + +type ValidGenRequiredInt8MapStruct struct { + Field map[int8]int8 `valid:"required"` +} + +type ValidatorRequiredInt8MapStruct struct { + Field map[int8]int8 `validate:"required"` +} + +type ValidGenRequiredInt16MapStruct struct { + Field map[int16]int16 `valid:"required"` +} + +type ValidatorRequiredInt16MapStruct struct { + Field map[int16]int16 `validate:"required"` +} + +type ValidGenRequiredInt32MapStruct struct { + Field map[int32]int32 `valid:"required"` +} + +type ValidatorRequiredInt32MapStruct struct { + Field map[int32]int32 `validate:"required"` +} + +type ValidGenRequiredInt64MapStruct struct { + Field map[int64]int64 `valid:"required"` +} + +type ValidatorRequiredInt64MapStruct struct { + Field map[int64]int64 `validate:"required"` +} + +type ValidGenRequiredUintMapStruct struct { + Field map[uint]uint `valid:"required"` +} + +type ValidatorRequiredUintMapStruct struct { + Field map[uint]uint `validate:"required"` +} + +type ValidGenRequiredUint8MapStruct struct { + Field map[uint8]uint8 `valid:"required"` +} + +type ValidatorRequiredUint8MapStruct struct { + Field map[uint8]uint8 `validate:"required"` +} + +type ValidGenRequiredUint16MapStruct struct { + Field map[uint16]uint16 `valid:"required"` +} + +type ValidatorRequiredUint16MapStruct struct { + Field map[uint16]uint16 `validate:"required"` +} + +type ValidGenRequiredUint32MapStruct struct { + Field map[uint32]uint32 `valid:"required"` +} + +type ValidatorRequiredUint32MapStruct struct { + Field map[uint32]uint32 `validate:"required"` +} + +type ValidGenRequiredUint64MapStruct struct { + Field map[uint64]uint64 `valid:"required"` +} + +type ValidatorRequiredUint64MapStruct struct { + Field map[uint64]uint64 `validate:"required"` +} + +type ValidGenRequiredFloat32MapStruct struct { + Field map[float32]float32 `valid:"required"` +} + +type ValidatorRequiredFloat32MapStruct struct { + Field map[float32]float32 `validate:"required"` +} + +type ValidGenRequiredFloat64MapStruct struct { + Field map[float64]float64 `valid:"required"` +} + +type ValidatorRequiredFloat64MapStruct struct { + Field map[float64]float64 `validate:"required"` +} + +type ValidGenRequiredBoolMapStruct struct { + Field map[bool]bool `valid:"required"` +} + +type ValidatorRequiredBoolMapStruct struct { + Field map[bool]bool `validate:"required"` +} + +type ValidGenEqStringStruct struct { + Field string `valid:"eq=abcde"` +} + +type ValidatorEqStringStruct struct { + Field string `validate:"eq=abcde"` +} + +type ValidGenEqIntStruct struct { + Field int `valid:"eq=32"` +} + +type ValidatorEqIntStruct struct { + Field int `validate:"eq=32"` +} + +type ValidGenEqInt8Struct struct { + Field int8 `valid:"eq=32"` +} + +type ValidatorEqInt8Struct struct { + Field int8 `validate:"eq=32"` +} + +type ValidGenEqInt16Struct struct { + Field int16 `valid:"eq=32"` +} + +type ValidatorEqInt16Struct struct { + Field int16 `validate:"eq=32"` +} + +type ValidGenEqInt32Struct struct { + Field int32 `valid:"eq=32"` +} + +type ValidatorEqInt32Struct struct { + Field int32 `validate:"eq=32"` +} + +type ValidGenEqInt64Struct struct { + Field int64 `valid:"eq=32"` +} + +type ValidatorEqInt64Struct struct { + Field int64 `validate:"eq=32"` +} + +type ValidGenEqUintStruct struct { + Field uint `valid:"eq=32"` +} + +type ValidatorEqUintStruct struct { + Field uint `validate:"eq=32"` +} + +type ValidGenEqUint8Struct struct { + Field uint8 `valid:"eq=32"` +} + +type ValidatorEqUint8Struct struct { + Field uint8 `validate:"eq=32"` +} + +type ValidGenEqUint16Struct struct { + Field uint16 `valid:"eq=32"` +} + +type ValidatorEqUint16Struct struct { + Field uint16 `validate:"eq=32"` +} + +type ValidGenEqUint32Struct struct { + Field uint32 `valid:"eq=32"` +} + +type ValidatorEqUint32Struct struct { + Field uint32 `validate:"eq=32"` +} + +type ValidGenEqUint64Struct struct { + Field uint64 `valid:"eq=32"` +} + +type ValidatorEqUint64Struct struct { + Field uint64 `validate:"eq=32"` +} + +type ValidGenEqFloat32Struct struct { + Field float32 `valid:"eq=12.34"` +} + +type ValidatorEqFloat32Struct struct { + Field float32 `validate:"eq=12.34"` +} + +type ValidGenEqFloat64Struct struct { + Field float64 `valid:"eq=12.34"` +} + +type ValidatorEqFloat64Struct struct { + Field float64 `validate:"eq=12.34"` +} + +type ValidGenEqBoolStruct struct { + Field bool `valid:"eq=true"` +} + +type ValidatorEqBoolStruct struct { + Field bool `validate:"eq=true"` +} + +type ValidGenNeqStringStruct struct { + Field string `valid:"neq=abcde"` +} + +type ValidatorNeqStringStruct struct { + Field string `validate:"ne=abcde"` +} + +type ValidGenNeqIntStruct struct { + Field int `valid:"neq=32"` +} + +type ValidatorNeqIntStruct struct { + Field int `validate:"ne=32"` +} + +type ValidGenNeqInt8Struct struct { + Field int8 `valid:"neq=32"` +} + +type ValidatorNeqInt8Struct struct { + Field int8 `validate:"ne=32"` +} + +type ValidGenNeqInt16Struct struct { + Field int16 `valid:"neq=32"` +} + +type ValidatorNeqInt16Struct struct { + Field int16 `validate:"ne=32"` +} + +type ValidGenNeqInt32Struct struct { + Field int32 `valid:"neq=32"` +} + +type ValidatorNeqInt32Struct struct { + Field int32 `validate:"ne=32"` +} + +type ValidGenNeqInt64Struct struct { + Field int64 `valid:"neq=32"` +} + +type ValidatorNeqInt64Struct struct { + Field int64 `validate:"ne=32"` +} + +type ValidGenNeqUintStruct struct { + Field uint `valid:"neq=32"` +} + +type ValidatorNeqUintStruct struct { + Field uint `validate:"ne=32"` +} + +type ValidGenNeqUint8Struct struct { + Field uint8 `valid:"neq=32"` +} + +type ValidatorNeqUint8Struct struct { + Field uint8 `validate:"ne=32"` +} + +type ValidGenNeqUint16Struct struct { + Field uint16 `valid:"neq=32"` +} + +type ValidatorNeqUint16Struct struct { + Field uint16 `validate:"ne=32"` +} + +type ValidGenNeqUint32Struct struct { + Field uint32 `valid:"neq=32"` +} + +type ValidatorNeqUint32Struct struct { + Field uint32 `validate:"ne=32"` +} + +type ValidGenNeqUint64Struct struct { + Field uint64 `valid:"neq=32"` +} + +type ValidatorNeqUint64Struct struct { + Field uint64 `validate:"ne=32"` +} + +type ValidGenNeqFloat32Struct struct { + Field float32 `valid:"neq=12.34"` +} + +type ValidatorNeqFloat32Struct struct { + Field float32 `validate:"ne=12.34"` +} + +type ValidGenNeqFloat64Struct struct { + Field float64 `valid:"neq=12.34"` +} + +type ValidatorNeqFloat64Struct struct { + Field float64 `validate:"ne=12.34"` +} + +type ValidGenNeqBoolStruct struct { + Field bool `valid:"neq=true"` +} + +type ValidatorNeqBoolStruct struct { + Field bool `validate:"ne=true"` +} + +type ValidGenGtIntStruct struct { + Field int `valid:"gt=32"` +} + +type ValidatorGtIntStruct struct { + Field int `validate:"gt=32"` +} + +type ValidGenGtInt8Struct struct { + Field int8 `valid:"gt=32"` +} + +type ValidatorGtInt8Struct struct { + Field int8 `validate:"gt=32"` +} + +type ValidGenGtInt16Struct struct { + Field int16 `valid:"gt=32"` +} + +type ValidatorGtInt16Struct struct { + Field int16 `validate:"gt=32"` +} + +type ValidGenGtInt32Struct struct { + Field int32 `valid:"gt=32"` +} + +type ValidatorGtInt32Struct struct { + Field int32 `validate:"gt=32"` +} + +type ValidGenGtInt64Struct struct { + Field int64 `valid:"gt=32"` +} + +type ValidatorGtInt64Struct struct { + Field int64 `validate:"gt=32"` +} + +type ValidGenGtUintStruct struct { + Field uint `valid:"gt=32"` +} + +type ValidatorGtUintStruct struct { + Field uint `validate:"gt=32"` +} + +type ValidGenGtUint8Struct struct { + Field uint8 `valid:"gt=32"` +} + +type ValidatorGtUint8Struct struct { + Field uint8 `validate:"gt=32"` +} + +type ValidGenGtUint16Struct struct { + Field uint16 `valid:"gt=32"` +} + +type ValidatorGtUint16Struct struct { + Field uint16 `validate:"gt=32"` +} + +type ValidGenGtUint32Struct struct { + Field uint32 `valid:"gt=32"` +} + +type ValidatorGtUint32Struct struct { + Field uint32 `validate:"gt=32"` +} + +type ValidGenGtUint64Struct struct { + Field uint64 `valid:"gt=32"` +} + +type ValidatorGtUint64Struct struct { + Field uint64 `validate:"gt=32"` +} + +type ValidGenGtFloat32Struct struct { + Field float32 `valid:"gt=12.34"` +} + +type ValidatorGtFloat32Struct struct { + Field float32 `validate:"gt=12.34"` +} + +type ValidGenGtFloat64Struct struct { + Field float64 `valid:"gt=12.34"` +} + +type ValidatorGtFloat64Struct struct { + Field float64 `validate:"gt=12.34"` +} + +type ValidGenGteIntStruct struct { + Field int `valid:"gte=32"` +} + +type ValidatorGteIntStruct struct { + Field int `validate:"gte=32"` +} + +type ValidGenGteInt8Struct struct { + Field int8 `valid:"gte=32"` +} + +type ValidatorGteInt8Struct struct { + Field int8 `validate:"gte=32"` +} + +type ValidGenGteInt16Struct struct { + Field int16 `valid:"gte=32"` +} + +type ValidatorGteInt16Struct struct { + Field int16 `validate:"gte=32"` +} + +type ValidGenGteInt32Struct struct { + Field int32 `valid:"gte=32"` +} + +type ValidatorGteInt32Struct struct { + Field int32 `validate:"gte=32"` +} + +type ValidGenGteInt64Struct struct { + Field int64 `valid:"gte=32"` +} + +type ValidatorGteInt64Struct struct { + Field int64 `validate:"gte=32"` +} + +type ValidGenGteUintStruct struct { + Field uint `valid:"gte=32"` +} + +type ValidatorGteUintStruct struct { + Field uint `validate:"gte=32"` +} + +type ValidGenGteUint8Struct struct { + Field uint8 `valid:"gte=32"` +} + +type ValidatorGteUint8Struct struct { + Field uint8 `validate:"gte=32"` +} + +type ValidGenGteUint16Struct struct { + Field uint16 `valid:"gte=32"` +} + +type ValidatorGteUint16Struct struct { + Field uint16 `validate:"gte=32"` +} + +type ValidGenGteUint32Struct struct { + Field uint32 `valid:"gte=32"` +} + +type ValidatorGteUint32Struct struct { + Field uint32 `validate:"gte=32"` +} + +type ValidGenGteUint64Struct struct { + Field uint64 `valid:"gte=32"` +} + +type ValidatorGteUint64Struct struct { + Field uint64 `validate:"gte=32"` +} + +type ValidGenGteFloat32Struct struct { + Field float32 `valid:"gte=12.34"` +} + +type ValidatorGteFloat32Struct struct { + Field float32 `validate:"gte=12.34"` +} + +type ValidGenGteFloat64Struct struct { + Field float64 `valid:"gte=12.34"` +} + +type ValidatorGteFloat64Struct struct { + Field float64 `validate:"gte=12.34"` +} + +type ValidGenLtIntStruct struct { + Field int `valid:"lt=32"` +} + +type ValidatorLtIntStruct struct { + Field int `validate:"lt=32"` +} + +type ValidGenLtInt8Struct struct { + Field int8 `valid:"lt=32"` +} + +type ValidatorLtInt8Struct struct { + Field int8 `validate:"lt=32"` +} + +type ValidGenLtInt16Struct struct { + Field int16 `valid:"lt=32"` +} + +type ValidatorLtInt16Struct struct { + Field int16 `validate:"lt=32"` +} + +type ValidGenLtInt32Struct struct { + Field int32 `valid:"lt=32"` +} + +type ValidatorLtInt32Struct struct { + Field int32 `validate:"lt=32"` +} + +type ValidGenLtInt64Struct struct { + Field int64 `valid:"lt=32"` +} + +type ValidatorLtInt64Struct struct { + Field int64 `validate:"lt=32"` +} + +type ValidGenLtUintStruct struct { + Field uint `valid:"lt=32"` +} + +type ValidatorLtUintStruct struct { + Field uint `validate:"lt=32"` +} + +type ValidGenLtUint8Struct struct { + Field uint8 `valid:"lt=32"` +} + +type ValidatorLtUint8Struct struct { + Field uint8 `validate:"lt=32"` +} + +type ValidGenLtUint16Struct struct { + Field uint16 `valid:"lt=32"` +} + +type ValidatorLtUint16Struct struct { + Field uint16 `validate:"lt=32"` +} + +type ValidGenLtUint32Struct struct { + Field uint32 `valid:"lt=32"` +} + +type ValidatorLtUint32Struct struct { + Field uint32 `validate:"lt=32"` +} + +type ValidGenLtUint64Struct struct { + Field uint64 `valid:"lt=32"` +} + +type ValidatorLtUint64Struct struct { + Field uint64 `validate:"lt=32"` +} + +type ValidGenLtFloat32Struct struct { + Field float32 `valid:"lt=12.34"` +} + +type ValidatorLtFloat32Struct struct { + Field float32 `validate:"lt=12.34"` +} + +type ValidGenLtFloat64Struct struct { + Field float64 `valid:"lt=12.34"` +} + +type ValidatorLtFloat64Struct struct { + Field float64 `validate:"lt=12.34"` +} + +type ValidGenLteIntStruct struct { + Field int `valid:"lte=32"` +} + +type ValidatorLteIntStruct struct { + Field int `validate:"lte=32"` +} + +type ValidGenLteInt8Struct struct { + Field int8 `valid:"lte=32"` +} + +type ValidatorLteInt8Struct struct { + Field int8 `validate:"lte=32"` +} + +type ValidGenLteInt16Struct struct { + Field int16 `valid:"lte=32"` +} + +type ValidatorLteInt16Struct struct { + Field int16 `validate:"lte=32"` +} + +type ValidGenLteInt32Struct struct { + Field int32 `valid:"lte=32"` +} + +type ValidatorLteInt32Struct struct { + Field int32 `validate:"lte=32"` +} + +type ValidGenLteInt64Struct struct { + Field int64 `valid:"lte=32"` +} + +type ValidatorLteInt64Struct struct { + Field int64 `validate:"lte=32"` +} + +type ValidGenLteUintStruct struct { + Field uint `valid:"lte=32"` +} + +type ValidatorLteUintStruct struct { + Field uint `validate:"lte=32"` +} + +type ValidGenLteUint8Struct struct { + Field uint8 `valid:"lte=32"` +} + +type ValidatorLteUint8Struct struct { + Field uint8 `validate:"lte=32"` +} + +type ValidGenLteUint16Struct struct { + Field uint16 `valid:"lte=32"` +} + +type ValidatorLteUint16Struct struct { + Field uint16 `validate:"lte=32"` +} + +type ValidGenLteUint32Struct struct { + Field uint32 `valid:"lte=32"` +} + +type ValidatorLteUint32Struct struct { + Field uint32 `validate:"lte=32"` +} + +type ValidGenLteUint64Struct struct { + Field uint64 `valid:"lte=32"` +} + +type ValidatorLteUint64Struct struct { + Field uint64 `validate:"lte=32"` +} + +type ValidGenLteFloat32Struct struct { + Field float32 `valid:"lte=12.34"` +} + +type ValidatorLteFloat32Struct struct { + Field float32 `validate:"lte=12.34"` +} + +type ValidGenLteFloat64Struct struct { + Field float64 `valid:"lte=12.34"` +} + +type ValidatorLteFloat64Struct struct { + Field float64 `validate:"lte=12.34"` +} + +type ValidGenMinStringStruct struct { + Field string `valid:"min=5"` +} + +type ValidatorMinStringStruct struct { + Field string `validate:"min=5"` +} + +type ValidGenMinStringSliceStruct struct { + Field []string `valid:"min=2"` +} + +type ValidatorMinStringSliceStruct struct { + Field []string `validate:"min=2"` +} + +type ValidGenMinIntSliceStruct struct { + Field []int `valid:"min=2"` +} + +type ValidatorMinIntSliceStruct struct { + Field []int `validate:"min=2"` +} + +type ValidGenMinInt8SliceStruct struct { + Field []int8 `valid:"min=2"` +} + +type ValidatorMinInt8SliceStruct struct { + Field []int8 `validate:"min=2"` +} + +type ValidGenMinInt16SliceStruct struct { + Field []int16 `valid:"min=2"` +} + +type ValidatorMinInt16SliceStruct struct { + Field []int16 `validate:"min=2"` +} + +type ValidGenMinInt32SliceStruct struct { + Field []int32 `valid:"min=2"` +} + +type ValidatorMinInt32SliceStruct struct { + Field []int32 `validate:"min=2"` +} + +type ValidGenMinInt64SliceStruct struct { + Field []int64 `valid:"min=2"` +} + +type ValidatorMinInt64SliceStruct struct { + Field []int64 `validate:"min=2"` +} + +type ValidGenMinUintSliceStruct struct { + Field []uint `valid:"min=2"` +} + +type ValidatorMinUintSliceStruct struct { + Field []uint `validate:"min=2"` +} + +type ValidGenMinUint8SliceStruct struct { + Field []uint8 `valid:"min=2"` +} + +type ValidatorMinUint8SliceStruct struct { + Field []uint8 `validate:"min=2"` +} + +type ValidGenMinUint16SliceStruct struct { + Field []uint16 `valid:"min=2"` +} + +type ValidatorMinUint16SliceStruct struct { + Field []uint16 `validate:"min=2"` +} + +type ValidGenMinUint32SliceStruct struct { + Field []uint32 `valid:"min=2"` +} + +type ValidatorMinUint32SliceStruct struct { + Field []uint32 `validate:"min=2"` +} + +type ValidGenMinUint64SliceStruct struct { + Field []uint64 `valid:"min=2"` +} + +type ValidatorMinUint64SliceStruct struct { + Field []uint64 `validate:"min=2"` +} + +type ValidGenMinFloat32SliceStruct struct { + Field []float32 `valid:"min=2"` +} + +type ValidatorMinFloat32SliceStruct struct { + Field []float32 `validate:"min=2"` +} + +type ValidGenMinFloat64SliceStruct struct { + Field []float64 `valid:"min=2"` +} + +type ValidatorMinFloat64SliceStruct struct { + Field []float64 `validate:"min=2"` +} + +type ValidGenMinBoolSliceStruct struct { + Field []bool `valid:"min=2"` +} + +type ValidatorMinBoolSliceStruct struct { + Field []bool `validate:"min=2"` +} + +type ValidGenMinStringMapStruct struct { + Field map[string]string `valid:"min=2"` +} + +type ValidatorMinStringMapStruct struct { + Field map[string]string `validate:"min=2"` +} + +type ValidGenMinIntMapStruct struct { + Field map[int]int `valid:"min=2"` +} + +type ValidatorMinIntMapStruct struct { + Field map[int]int `validate:"min=2"` +} + +type ValidGenMinInt8MapStruct struct { + Field map[int8]int8 `valid:"min=2"` +} + +type ValidatorMinInt8MapStruct struct { + Field map[int8]int8 `validate:"min=2"` +} + +type ValidGenMinInt16MapStruct struct { + Field map[int16]int16 `valid:"min=2"` +} + +type ValidatorMinInt16MapStruct struct { + Field map[int16]int16 `validate:"min=2"` +} + +type ValidGenMinInt32MapStruct struct { + Field map[int32]int32 `valid:"min=2"` +} + +type ValidatorMinInt32MapStruct struct { + Field map[int32]int32 `validate:"min=2"` +} + +type ValidGenMinInt64MapStruct struct { + Field map[int64]int64 `valid:"min=2"` +} + +type ValidatorMinInt64MapStruct struct { + Field map[int64]int64 `validate:"min=2"` +} + +type ValidGenMinUintMapStruct struct { + Field map[uint]uint `valid:"min=2"` +} + +type ValidatorMinUintMapStruct struct { + Field map[uint]uint `validate:"min=2"` +} + +type ValidGenMinUint8MapStruct struct { + Field map[uint8]uint8 `valid:"min=2"` +} + +type ValidatorMinUint8MapStruct struct { + Field map[uint8]uint8 `validate:"min=2"` +} + +type ValidGenMinUint16MapStruct struct { + Field map[uint16]uint16 `valid:"min=2"` +} + +type ValidatorMinUint16MapStruct struct { + Field map[uint16]uint16 `validate:"min=2"` +} + +type ValidGenMinUint32MapStruct struct { + Field map[uint32]uint32 `valid:"min=2"` +} + +type ValidatorMinUint32MapStruct struct { + Field map[uint32]uint32 `validate:"min=2"` +} + +type ValidGenMinUint64MapStruct struct { + Field map[uint64]uint64 `valid:"min=2"` +} + +type ValidatorMinUint64MapStruct struct { + Field map[uint64]uint64 `validate:"min=2"` +} + +type ValidGenMinFloat32MapStruct struct { + Field map[float32]float32 `valid:"min=2"` +} + +type ValidatorMinFloat32MapStruct struct { + Field map[float32]float32 `validate:"min=2"` +} + +type ValidGenMinFloat64MapStruct struct { + Field map[float64]float64 `valid:"min=2"` +} + +type ValidatorMinFloat64MapStruct struct { + Field map[float64]float64 `validate:"min=2"` +} + +type ValidGenMinBoolMapStruct struct { + Field map[bool]bool `valid:"min=2"` +} + +type ValidatorMinBoolMapStruct struct { + Field map[bool]bool `validate:"min=2"` +} + +type ValidGenMaxStringStruct struct { + Field string `valid:"max=3"` +} + +type ValidatorMaxStringStruct struct { + Field string `validate:"max=3"` +} + +type ValidGenMaxStringSliceStruct struct { + Field []string `valid:"max=2"` +} + +type ValidatorMaxStringSliceStruct struct { + Field []string `validate:"max=2"` +} + +type ValidGenMaxIntSliceStruct struct { + Field []int `valid:"max=2"` +} + +type ValidatorMaxIntSliceStruct struct { + Field []int `validate:"max=2"` +} + +type ValidGenMaxInt8SliceStruct struct { + Field []int8 `valid:"max=2"` +} + +type ValidatorMaxInt8SliceStruct struct { + Field []int8 `validate:"max=2"` +} + +type ValidGenMaxInt16SliceStruct struct { + Field []int16 `valid:"max=2"` +} + +type ValidatorMaxInt16SliceStruct struct { + Field []int16 `validate:"max=2"` +} + +type ValidGenMaxInt32SliceStruct struct { + Field []int32 `valid:"max=2"` +} + +type ValidatorMaxInt32SliceStruct struct { + Field []int32 `validate:"max=2"` +} + +type ValidGenMaxInt64SliceStruct struct { + Field []int64 `valid:"max=2"` +} + +type ValidatorMaxInt64SliceStruct struct { + Field []int64 `validate:"max=2"` +} + +type ValidGenMaxUintSliceStruct struct { + Field []uint `valid:"max=2"` +} + +type ValidatorMaxUintSliceStruct struct { + Field []uint `validate:"max=2"` +} + +type ValidGenMaxUint8SliceStruct struct { + Field []uint8 `valid:"max=2"` +} + +type ValidatorMaxUint8SliceStruct struct { + Field []uint8 `validate:"max=2"` +} + +type ValidGenMaxUint16SliceStruct struct { + Field []uint16 `valid:"max=2"` +} + +type ValidatorMaxUint16SliceStruct struct { + Field []uint16 `validate:"max=2"` +} + +type ValidGenMaxUint32SliceStruct struct { + Field []uint32 `valid:"max=2"` +} + +type ValidatorMaxUint32SliceStruct struct { + Field []uint32 `validate:"max=2"` +} + +type ValidGenMaxUint64SliceStruct struct { + Field []uint64 `valid:"max=2"` +} + +type ValidatorMaxUint64SliceStruct struct { + Field []uint64 `validate:"max=2"` +} + +type ValidGenMaxFloat32SliceStruct struct { + Field []float32 `valid:"max=2"` +} + +type ValidatorMaxFloat32SliceStruct struct { + Field []float32 `validate:"max=2"` +} + +type ValidGenMaxFloat64SliceStruct struct { + Field []float64 `valid:"max=2"` +} + +type ValidatorMaxFloat64SliceStruct struct { + Field []float64 `validate:"max=2"` +} + +type ValidGenMaxBoolSliceStruct struct { + Field []bool `valid:"max=2"` +} + +type ValidatorMaxBoolSliceStruct struct { + Field []bool `validate:"max=2"` +} + +type ValidGenMaxStringMapStruct struct { + Field map[string]string `valid:"max=2"` +} + +type ValidatorMaxStringMapStruct struct { + Field map[string]string `validate:"max=2"` +} + +type ValidGenMaxIntMapStruct struct { + Field map[int]int `valid:"max=2"` +} + +type ValidatorMaxIntMapStruct struct { + Field map[int]int `validate:"max=2"` +} + +type ValidGenMaxInt8MapStruct struct { + Field map[int8]int8 `valid:"max=2"` +} + +type ValidatorMaxInt8MapStruct struct { + Field map[int8]int8 `validate:"max=2"` +} + +type ValidGenMaxInt16MapStruct struct { + Field map[int16]int16 `valid:"max=2"` +} + +type ValidatorMaxInt16MapStruct struct { + Field map[int16]int16 `validate:"max=2"` +} + +type ValidGenMaxInt32MapStruct struct { + Field map[int32]int32 `valid:"max=2"` +} + +type ValidatorMaxInt32MapStruct struct { + Field map[int32]int32 `validate:"max=2"` +} + +type ValidGenMaxInt64MapStruct struct { + Field map[int64]int64 `valid:"max=2"` +} + +type ValidatorMaxInt64MapStruct struct { + Field map[int64]int64 `validate:"max=2"` +} + +type ValidGenMaxUintMapStruct struct { + Field map[uint]uint `valid:"max=2"` +} + +type ValidatorMaxUintMapStruct struct { + Field map[uint]uint `validate:"max=2"` +} + +type ValidGenMaxUint8MapStruct struct { + Field map[uint8]uint8 `valid:"max=2"` +} + +type ValidatorMaxUint8MapStruct struct { + Field map[uint8]uint8 `validate:"max=2"` +} + +type ValidGenMaxUint16MapStruct struct { + Field map[uint16]uint16 `valid:"max=2"` +} + +type ValidatorMaxUint16MapStruct struct { + Field map[uint16]uint16 `validate:"max=2"` +} + +type ValidGenMaxUint32MapStruct struct { + Field map[uint32]uint32 `valid:"max=2"` +} + +type ValidatorMaxUint32MapStruct struct { + Field map[uint32]uint32 `validate:"max=2"` +} + +type ValidGenMaxUint64MapStruct struct { + Field map[uint64]uint64 `valid:"max=2"` +} + +type ValidatorMaxUint64MapStruct struct { + Field map[uint64]uint64 `validate:"max=2"` +} + +type ValidGenMaxFloat32MapStruct struct { + Field map[float32]float32 `valid:"max=2"` +} + +type ValidatorMaxFloat32MapStruct struct { + Field map[float32]float32 `validate:"max=2"` +} + +type ValidGenMaxFloat64MapStruct struct { + Field map[float64]float64 `valid:"max=2"` +} + +type ValidatorMaxFloat64MapStruct struct { + Field map[float64]float64 `validate:"max=2"` +} + +type ValidGenMaxBoolMapStruct struct { + Field map[bool]bool `valid:"max=1"` +} + +type ValidatorMaxBoolMapStruct struct { + Field map[bool]bool `validate:"max=1"` +} + +type ValidGenEq_ignore_caseStringStruct struct { + Field string `valid:"eq_ignore_case=abcde"` +} + +type ValidatorEq_ignore_caseStringStruct struct { + Field string `validate:"eq_ignore_case=abcde"` +} + +type ValidGenNeq_ignore_caseStringStruct struct { + Field string `valid:"neq_ignore_case=abcde"` +} + +type ValidatorNeq_ignore_caseStringStruct struct { + Field string `validate:"ne_ignore_case=abcde"` +} + +type ValidGenLenStringStruct struct { + Field string `valid:"len=2"` +} + +type ValidatorLenStringStruct struct { + Field string `validate:"len=2"` +} + +type ValidGenLenStringSliceStruct struct { + Field []string `valid:"len=2"` +} + +type ValidatorLenStringSliceStruct struct { + Field []string `validate:"len=2"` +} + +type ValidGenLenIntSliceStruct struct { + Field []int `valid:"len=2"` +} + +type ValidatorLenIntSliceStruct struct { + Field []int `validate:"len=2"` +} + +type ValidGenLenInt8SliceStruct struct { + Field []int8 `valid:"len=2"` +} + +type ValidatorLenInt8SliceStruct struct { + Field []int8 `validate:"len=2"` +} + +type ValidGenLenInt16SliceStruct struct { + Field []int16 `valid:"len=2"` +} + +type ValidatorLenInt16SliceStruct struct { + Field []int16 `validate:"len=2"` +} + +type ValidGenLenInt32SliceStruct struct { + Field []int32 `valid:"len=2"` +} + +type ValidatorLenInt32SliceStruct struct { + Field []int32 `validate:"len=2"` +} + +type ValidGenLenInt64SliceStruct struct { + Field []int64 `valid:"len=2"` +} + +type ValidatorLenInt64SliceStruct struct { + Field []int64 `validate:"len=2"` +} + +type ValidGenLenUintSliceStruct struct { + Field []uint `valid:"len=2"` +} + +type ValidatorLenUintSliceStruct struct { + Field []uint `validate:"len=2"` +} + +type ValidGenLenUint8SliceStruct struct { + Field []uint8 `valid:"len=2"` +} + +type ValidatorLenUint8SliceStruct struct { + Field []uint8 `validate:"len=2"` +} + +type ValidGenLenUint16SliceStruct struct { + Field []uint16 `valid:"len=2"` +} + +type ValidatorLenUint16SliceStruct struct { + Field []uint16 `validate:"len=2"` +} + +type ValidGenLenUint32SliceStruct struct { + Field []uint32 `valid:"len=2"` +} + +type ValidatorLenUint32SliceStruct struct { + Field []uint32 `validate:"len=2"` +} + +type ValidGenLenUint64SliceStruct struct { + Field []uint64 `valid:"len=2"` +} + +type ValidatorLenUint64SliceStruct struct { + Field []uint64 `validate:"len=2"` +} + +type ValidGenLenFloat32SliceStruct struct { + Field []float32 `valid:"len=2"` +} + +type ValidatorLenFloat32SliceStruct struct { + Field []float32 `validate:"len=2"` +} + +type ValidGenLenFloat64SliceStruct struct { + Field []float64 `valid:"len=2"` +} + +type ValidatorLenFloat64SliceStruct struct { + Field []float64 `validate:"len=2"` +} + +type ValidGenLenBoolSliceStruct struct { + Field []bool `valid:"len=2"` +} + +type ValidatorLenBoolSliceStruct struct { + Field []bool `validate:"len=2"` +} + +type ValidGenLenStringMapStruct struct { + Field map[string]string `valid:"len=2"` +} + +type ValidatorLenStringMapStruct struct { + Field map[string]string `validate:"len=2"` +} + +type ValidGenLenIntMapStruct struct { + Field map[int]int `valid:"len=2"` +} + +type ValidatorLenIntMapStruct struct { + Field map[int]int `validate:"len=2"` +} + +type ValidGenLenInt8MapStruct struct { + Field map[int8]int8 `valid:"len=2"` +} + +type ValidatorLenInt8MapStruct struct { + Field map[int8]int8 `validate:"len=2"` +} + +type ValidGenLenInt16MapStruct struct { + Field map[int16]int16 `valid:"len=2"` +} + +type ValidatorLenInt16MapStruct struct { + Field map[int16]int16 `validate:"len=2"` +} + +type ValidGenLenInt32MapStruct struct { + Field map[int32]int32 `valid:"len=2"` +} + +type ValidatorLenInt32MapStruct struct { + Field map[int32]int32 `validate:"len=2"` +} + +type ValidGenLenInt64MapStruct struct { + Field map[int64]int64 `valid:"len=2"` +} + +type ValidatorLenInt64MapStruct struct { + Field map[int64]int64 `validate:"len=2"` +} + +type ValidGenLenUintMapStruct struct { + Field map[uint]uint `valid:"len=2"` +} + +type ValidatorLenUintMapStruct struct { + Field map[uint]uint `validate:"len=2"` +} + +type ValidGenLenUint8MapStruct struct { + Field map[uint8]uint8 `valid:"len=2"` +} + +type ValidatorLenUint8MapStruct struct { + Field map[uint8]uint8 `validate:"len=2"` +} + +type ValidGenLenUint16MapStruct struct { + Field map[uint16]uint16 `valid:"len=2"` +} + +type ValidatorLenUint16MapStruct struct { + Field map[uint16]uint16 `validate:"len=2"` +} + +type ValidGenLenUint32MapStruct struct { + Field map[uint32]uint32 `valid:"len=2"` +} + +type ValidatorLenUint32MapStruct struct { + Field map[uint32]uint32 `validate:"len=2"` +} + +type ValidGenLenUint64MapStruct struct { + Field map[uint64]uint64 `valid:"len=2"` +} + +type ValidatorLenUint64MapStruct struct { + Field map[uint64]uint64 `validate:"len=2"` +} + +type ValidGenLenFloat32MapStruct struct { + Field map[float32]float32 `valid:"len=2"` +} + +type ValidatorLenFloat32MapStruct struct { + Field map[float32]float32 `validate:"len=2"` +} + +type ValidGenLenFloat64MapStruct struct { + Field map[float64]float64 `valid:"len=2"` +} + +type ValidatorLenFloat64MapStruct struct { + Field map[float64]float64 `validate:"len=2"` +} + +type ValidGenLenBoolMapStruct struct { + Field map[bool]bool `valid:"len=2"` +} + +type ValidatorLenBoolMapStruct struct { + Field map[bool]bool `validate:"len=2"` +} + +type ValidGenInStringStruct struct { + Field string `valid:"in=ab cd ef"` +} + +type ValidatorInStringStruct struct { + Field string `validate:"oneof=ab cd ef"` +} + +type ValidGenInIntStruct struct { + Field int `valid:"in=12 34 56"` +} + +type ValidatorInIntStruct struct { + Field int `validate:"oneof=12 34 56"` +} + +type ValidGenInInt8Struct struct { + Field int8 `valid:"in=12 34 56"` +} + +type ValidatorInInt8Struct struct { + Field int8 `validate:"oneof=12 34 56"` +} + +type ValidGenInInt16Struct struct { + Field int16 `valid:"in=12 34 56"` +} + +type ValidatorInInt16Struct struct { + Field int16 `validate:"oneof=12 34 56"` +} + +type ValidGenInInt32Struct struct { + Field int32 `valid:"in=12 34 56"` +} + +type ValidatorInInt32Struct struct { + Field int32 `validate:"oneof=12 34 56"` +} + +type ValidGenInInt64Struct struct { + Field int64 `valid:"in=12 34 56"` +} + +type ValidatorInInt64Struct struct { + Field int64 `validate:"oneof=12 34 56"` +} + +type ValidGenInUintStruct struct { + Field uint `valid:"in=12 34 56"` +} + +type ValidatorInUintStruct struct { + Field uint `validate:"oneof=12 34 56"` +} + +type ValidGenInUint8Struct struct { + Field uint8 `valid:"in=12 34 56"` +} + +type ValidatorInUint8Struct struct { + Field uint8 `validate:"oneof=12 34 56"` +} + +type ValidGenInUint16Struct struct { + Field uint16 `valid:"in=12 34 56"` +} + +type ValidatorInUint16Struct struct { + Field uint16 `validate:"oneof=12 34 56"` +} + +type ValidGenInUint32Struct struct { + Field uint32 `valid:"in=12 34 56"` +} + +type ValidatorInUint32Struct struct { + Field uint32 `validate:"oneof=12 34 56"` +} + +type ValidGenInUint64Struct struct { + Field uint64 `valid:"in=12 34 56"` +} + +type ValidatorInUint64Struct struct { + Field uint64 `validate:"oneof=12 34 56"` +} + +func BenchmarkValidGenEmailString(b *testing.B) { + data := &ValidGenEmailStringStruct{ + Field: "abcde@example.com", + } + + for b.Loop() { + if err := ValidGenEmailStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEmailString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEmailStringStruct{ + Field: "abcde@example.com", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredString(b *testing.B) { + data := &ValidGenRequiredStringStruct{ + Field: "abcde", + } + + for b.Loop() { + if err := ValidGenRequiredStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredStringStruct{ + Field: "abcde", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt(b *testing.B) { + data := &ValidGenRequiredIntStruct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredIntStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredIntStruct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt8(b *testing.B) { + data := &ValidGenRequiredInt8Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredInt8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt8Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt16(b *testing.B) { + data := &ValidGenRequiredInt16Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredInt16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt16Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt32(b *testing.B) { + data := &ValidGenRequiredInt32Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredInt32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt32Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt64(b *testing.B) { + data := &ValidGenRequiredInt64Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredInt64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt64Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint(b *testing.B) { + data := &ValidGenRequiredUintStruct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredUintStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUintStruct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint8(b *testing.B) { + data := &ValidGenRequiredUint8Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredUint8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint8Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint16(b *testing.B) { + data := &ValidGenRequiredUint16Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredUint16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint16Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint32(b *testing.B) { + data := &ValidGenRequiredUint32Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredUint32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint32Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint64(b *testing.B) { + data := &ValidGenRequiredUint64Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenRequiredUint64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint64Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat32(b *testing.B) { + data := &ValidGenRequiredFloat32Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := ValidGenRequiredFloat32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredFloat32Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat64(b *testing.B) { + data := &ValidGenRequiredFloat64Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := ValidGenRequiredFloat64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredFloat64Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredBool(b *testing.B) { + data := &ValidGenRequiredBoolStruct{ + Field: true, + } + + for b.Loop() { + if err := ValidGenRequiredBoolStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredBool(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredBoolStruct{ + Field: true, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredStringSlice(b *testing.B) { + data := &ValidGenRequiredStringSliceStruct{ + Field: []string{"abcde"}, + } + + for b.Loop() { + if err := ValidGenRequiredStringSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredStringSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredStringSliceStruct{ + Field: []string{"abcde"}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredIntSlice(b *testing.B) { + data := &ValidGenRequiredIntSliceStruct{ + Field: []int{32}, + } + + for b.Loop() { + if err := ValidGenRequiredIntSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredIntSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredIntSliceStruct{ + Field: []int{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt8Slice(b *testing.B) { + data := &ValidGenRequiredInt8SliceStruct{ + Field: []int8{32}, + } + + for b.Loop() { + if err := ValidGenRequiredInt8SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt8Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt8SliceStruct{ + Field: []int8{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt16Slice(b *testing.B) { + data := &ValidGenRequiredInt16SliceStruct{ + Field: []int16{32}, + } + + for b.Loop() { + if err := ValidGenRequiredInt16SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt16Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt16SliceStruct{ + Field: []int16{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt32Slice(b *testing.B) { + data := &ValidGenRequiredInt32SliceStruct{ + Field: []int32{32}, + } + + for b.Loop() { + if err := ValidGenRequiredInt32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt32SliceStruct{ + Field: []int32{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt64Slice(b *testing.B) { + data := &ValidGenRequiredInt64SliceStruct{ + Field: []int64{32}, + } + + for b.Loop() { + if err := ValidGenRequiredInt64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt64SliceStruct{ + Field: []int64{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUintSlice(b *testing.B) { + data := &ValidGenRequiredUintSliceStruct{ + Field: []uint{32}, + } + + for b.Loop() { + if err := ValidGenRequiredUintSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUintSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUintSliceStruct{ + Field: []uint{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint8Slice(b *testing.B) { + data := &ValidGenRequiredUint8SliceStruct{ + Field: []uint8{32}, + } + + for b.Loop() { + if err := ValidGenRequiredUint8SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint8Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint8SliceStruct{ + Field: []uint8{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint16Slice(b *testing.B) { + data := &ValidGenRequiredUint16SliceStruct{ + Field: []uint16{32}, + } + + for b.Loop() { + if err := ValidGenRequiredUint16SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint16Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint16SliceStruct{ + Field: []uint16{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint32Slice(b *testing.B) { + data := &ValidGenRequiredUint32SliceStruct{ + Field: []uint32{32}, + } + + for b.Loop() { + if err := ValidGenRequiredUint32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint32SliceStruct{ + Field: []uint32{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint64Slice(b *testing.B) { + data := &ValidGenRequiredUint64SliceStruct{ + Field: []uint64{32}, + } + + for b.Loop() { + if err := ValidGenRequiredUint64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint64SliceStruct{ + Field: []uint64{32}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat32Slice(b *testing.B) { + data := &ValidGenRequiredFloat32SliceStruct{ + Field: []float32{12.34}, + } + + for b.Loop() { + if err := ValidGenRequiredFloat32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredFloat32SliceStruct{ + Field: []float32{12.34}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat64Slice(b *testing.B) { + data := &ValidGenRequiredFloat64SliceStruct{ + Field: []float64{12.34}, + } + + for b.Loop() { + if err := ValidGenRequiredFloat64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredFloat64SliceStruct{ + Field: []float64{12.34}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredBoolSlice(b *testing.B) { + data := &ValidGenRequiredBoolSliceStruct{ + Field: []bool{true}, + } + + for b.Loop() { + if err := ValidGenRequiredBoolSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredBoolSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredBoolSliceStruct{ + Field: []bool{true}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredStringMap(b *testing.B) { + data := &ValidGenRequiredStringMapStruct{ + Field: map[string]string{"abcde": "value"}, + } + + for b.Loop() { + if err := ValidGenRequiredStringMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredStringMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredStringMapStruct{ + Field: map[string]string{"abcde": "value"}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredIntMap(b *testing.B) { + data := &ValidGenRequiredIntMapStruct{ + Field: map[int]int{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredIntMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredIntMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredIntMapStruct{ + Field: map[int]int{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt8Map(b *testing.B) { + data := &ValidGenRequiredInt8MapStruct{ + Field: map[int8]int8{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredInt8MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt8Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt8MapStruct{ + Field: map[int8]int8{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt16Map(b *testing.B) { + data := &ValidGenRequiredInt16MapStruct{ + Field: map[int16]int16{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredInt16MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt16Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt16MapStruct{ + Field: map[int16]int16{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt32Map(b *testing.B) { + data := &ValidGenRequiredInt32MapStruct{ + Field: map[int32]int32{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredInt32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt32MapStruct{ + Field: map[int32]int32{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt64Map(b *testing.B) { + data := &ValidGenRequiredInt64MapStruct{ + Field: map[int64]int64{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredInt64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredInt64MapStruct{ + Field: map[int64]int64{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUintMap(b *testing.B) { + data := &ValidGenRequiredUintMapStruct{ + Field: map[uint]uint{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredUintMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUintMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUintMapStruct{ + Field: map[uint]uint{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint8Map(b *testing.B) { + data := &ValidGenRequiredUint8MapStruct{ + Field: map[uint8]uint8{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredUint8MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint8Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint8MapStruct{ + Field: map[uint8]uint8{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint16Map(b *testing.B) { + data := &ValidGenRequiredUint16MapStruct{ + Field: map[uint16]uint16{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredUint16MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint16Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint16MapStruct{ + Field: map[uint16]uint16{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint32Map(b *testing.B) { + data := &ValidGenRequiredUint32MapStruct{ + Field: map[uint32]uint32{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredUint32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint32MapStruct{ + Field: map[uint32]uint32{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint64Map(b *testing.B) { + data := &ValidGenRequiredUint64MapStruct{ + Field: map[uint64]uint64{32: 64}, + } + + for b.Loop() { + if err := ValidGenRequiredUint64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredUint64MapStruct{ + Field: map[uint64]uint64{32: 64}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat32Map(b *testing.B) { + data := &ValidGenRequiredFloat32MapStruct{ + Field: map[float32]float32{12.34: 56.78}, + } + + for b.Loop() { + if err := ValidGenRequiredFloat32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredFloat32MapStruct{ + Field: map[float32]float32{12.34: 56.78}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat64Map(b *testing.B) { + data := &ValidGenRequiredFloat64MapStruct{ + Field: map[float64]float64{12.34: 56.78}, + } + + for b.Loop() { + if err := ValidGenRequiredFloat64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredFloat64MapStruct{ + Field: map[float64]float64{12.34: 56.78}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredBoolMap(b *testing.B) { + data := &ValidGenRequiredBoolMapStruct{ + Field: map[bool]bool{true: true}, + } + + for b.Loop() { + if err := ValidGenRequiredBoolMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredBoolMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorRequiredBoolMapStruct{ + Field: map[bool]bool{true: true}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqString(b *testing.B) { + data := &ValidGenEqStringStruct{ + Field: "abcde", + } + + for b.Loop() { + if err := ValidGenEqStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqStringStruct{ + Field: "abcde", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqInt(b *testing.B) { + data := &ValidGenEqIntStruct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqIntStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqInt(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqIntStruct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqInt8(b *testing.B) { + data := &ValidGenEqInt8Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqInt8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqInt8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqInt8Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqInt16(b *testing.B) { + data := &ValidGenEqInt16Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqInt16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqInt16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqInt16Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqInt32(b *testing.B) { + data := &ValidGenEqInt32Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqInt32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqInt32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqInt32Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqInt64(b *testing.B) { + data := &ValidGenEqInt64Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqInt64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqInt64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqInt64Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUint(b *testing.B) { + data := &ValidGenEqUintStruct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqUintStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUint(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqUintStruct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUint8(b *testing.B) { + data := &ValidGenEqUint8Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqUint8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUint8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqUint8Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUint16(b *testing.B) { + data := &ValidGenEqUint16Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqUint16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUint16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqUint16Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUint32(b *testing.B) { + data := &ValidGenEqUint32Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqUint32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUint32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqUint32Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUint64(b *testing.B) { + data := &ValidGenEqUint64Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenEqUint64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUint64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqUint64Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqFloat32(b *testing.B) { + data := &ValidGenEqFloat32Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := ValidGenEqFloat32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqFloat32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqFloat32Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqFloat64(b *testing.B) { + data := &ValidGenEqFloat64Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := ValidGenEqFloat64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqFloat64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqFloat64Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqBool(b *testing.B) { + data := &ValidGenEqBoolStruct{ + Field: true, + } + + for b.Loop() { + if err := ValidGenEqBoolStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqBool(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEqBoolStruct{ + Field: true, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqString(b *testing.B) { + data := &ValidGenNeqStringStruct{ + Field: "fghij", + } + + for b.Loop() { + if err := ValidGenNeqStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqStringStruct{ + Field: "fghij", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqInt(b *testing.B) { + data := &ValidGenNeqIntStruct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqIntStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqInt(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqIntStruct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqInt8(b *testing.B) { + data := &ValidGenNeqInt8Struct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqInt8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqInt8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqInt8Struct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqInt16(b *testing.B) { + data := &ValidGenNeqInt16Struct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqInt16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqInt16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqInt16Struct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqInt32(b *testing.B) { + data := &ValidGenNeqInt32Struct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqInt32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqInt32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqInt32Struct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqInt64(b *testing.B) { + data := &ValidGenNeqInt64Struct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqInt64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqInt64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqInt64Struct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUint(b *testing.B) { + data := &ValidGenNeqUintStruct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqUintStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUint(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqUintStruct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUint8(b *testing.B) { + data := &ValidGenNeqUint8Struct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqUint8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUint8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqUint8Struct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUint16(b *testing.B) { + data := &ValidGenNeqUint16Struct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqUint16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUint16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqUint16Struct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUint32(b *testing.B) { + data := &ValidGenNeqUint32Struct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqUint32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUint32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqUint32Struct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUint64(b *testing.B) { + data := &ValidGenNeqUint64Struct{ + Field: 64, + } + + for b.Loop() { + if err := ValidGenNeqUint64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUint64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqUint64Struct{ + Field: 64, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqFloat32(b *testing.B) { + data := &ValidGenNeqFloat32Struct{ + Field: 34.56, + } + + for b.Loop() { + if err := ValidGenNeqFloat32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqFloat32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqFloat32Struct{ + Field: 34.56, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqFloat64(b *testing.B) { + data := &ValidGenNeqFloat64Struct{ + Field: 34.56, + } + + for b.Loop() { + if err := ValidGenNeqFloat64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqFloat64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqFloat64Struct{ + Field: 34.56, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqBool(b *testing.B) { + data := &ValidGenNeqBoolStruct{ + Field: false, + } + + for b.Loop() { + if err := ValidGenNeqBoolStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqBool(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeqBoolStruct{ + Field: false, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtInt(b *testing.B) { + data := &ValidGenGtIntStruct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtIntStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtInt(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtIntStruct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtInt8(b *testing.B) { + data := &ValidGenGtInt8Struct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtInt8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtInt8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtInt8Struct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtInt16(b *testing.B) { + data := &ValidGenGtInt16Struct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtInt16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtInt16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtInt16Struct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtInt32(b *testing.B) { + data := &ValidGenGtInt32Struct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtInt32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtInt32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtInt32Struct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtInt64(b *testing.B) { + data := &ValidGenGtInt64Struct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtInt64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtInt64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtInt64Struct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUint(b *testing.B) { + data := &ValidGenGtUintStruct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtUintStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUint(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtUintStruct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUint8(b *testing.B) { + data := &ValidGenGtUint8Struct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtUint8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUint8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtUint8Struct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUint16(b *testing.B) { + data := &ValidGenGtUint16Struct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtUint16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUint16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtUint16Struct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUint32(b *testing.B) { + data := &ValidGenGtUint32Struct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtUint32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUint32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtUint32Struct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUint64(b *testing.B) { + data := &ValidGenGtUint64Struct{ + Field: 33, + } + + for b.Loop() { + if err := ValidGenGtUint64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUint64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtUint64Struct{ + Field: 33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtFloat32(b *testing.B) { + data := &ValidGenGtFloat32Struct{ + Field: 12.35, + } + + for b.Loop() { + if err := ValidGenGtFloat32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtFloat32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtFloat32Struct{ + Field: 12.35, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtFloat64(b *testing.B) { + data := &ValidGenGtFloat64Struct{ + Field: 12.35, + } + + for b.Loop() { + if err := ValidGenGtFloat64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtFloat64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGtFloat64Struct{ + Field: 12.35, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteInt(b *testing.B) { + data := &ValidGenGteIntStruct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteIntStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteInt(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteIntStruct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteInt8(b *testing.B) { + data := &ValidGenGteInt8Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteInt8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteInt8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteInt8Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteInt16(b *testing.B) { + data := &ValidGenGteInt16Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteInt16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteInt16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteInt16Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteInt32(b *testing.B) { + data := &ValidGenGteInt32Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteInt32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteInt32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteInt32Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteInt64(b *testing.B) { + data := &ValidGenGteInt64Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteInt64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteInt64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteInt64Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUint(b *testing.B) { + data := &ValidGenGteUintStruct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteUintStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUint(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteUintStruct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUint8(b *testing.B) { + data := &ValidGenGteUint8Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteUint8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUint8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteUint8Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUint16(b *testing.B) { + data := &ValidGenGteUint16Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteUint16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUint16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteUint16Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUint32(b *testing.B) { + data := &ValidGenGteUint32Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteUint32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUint32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteUint32Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUint64(b *testing.B) { + data := &ValidGenGteUint64Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenGteUint64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUint64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteUint64Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteFloat32(b *testing.B) { + data := &ValidGenGteFloat32Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := ValidGenGteFloat32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteFloat32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteFloat32Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteFloat64(b *testing.B) { + data := &ValidGenGteFloat64Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := ValidGenGteFloat64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteFloat64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorGteFloat64Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtInt(b *testing.B) { + data := &ValidGenLtIntStruct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtIntStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtInt(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtIntStruct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtInt8(b *testing.B) { + data := &ValidGenLtInt8Struct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtInt8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtInt8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtInt8Struct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtInt16(b *testing.B) { + data := &ValidGenLtInt16Struct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtInt16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtInt16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtInt16Struct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtInt32(b *testing.B) { + data := &ValidGenLtInt32Struct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtInt32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtInt32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtInt32Struct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtInt64(b *testing.B) { + data := &ValidGenLtInt64Struct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtInt64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtInt64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtInt64Struct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUint(b *testing.B) { + data := &ValidGenLtUintStruct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtUintStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUint(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtUintStruct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUint8(b *testing.B) { + data := &ValidGenLtUint8Struct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtUint8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUint8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtUint8Struct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUint16(b *testing.B) { + data := &ValidGenLtUint16Struct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtUint16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUint16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtUint16Struct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUint32(b *testing.B) { + data := &ValidGenLtUint32Struct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtUint32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUint32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtUint32Struct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUint64(b *testing.B) { + data := &ValidGenLtUint64Struct{ + Field: 31, + } + + for b.Loop() { + if err := ValidGenLtUint64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUint64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtUint64Struct{ + Field: 31, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtFloat32(b *testing.B) { + data := &ValidGenLtFloat32Struct{ + Field: 12.33, + } + + for b.Loop() { + if err := ValidGenLtFloat32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtFloat32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtFloat32Struct{ + Field: 12.33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtFloat64(b *testing.B) { + data := &ValidGenLtFloat64Struct{ + Field: 12.33, + } + + for b.Loop() { + if err := ValidGenLtFloat64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtFloat64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLtFloat64Struct{ + Field: 12.33, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteInt(b *testing.B) { + data := &ValidGenLteIntStruct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteIntStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteInt(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteIntStruct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteInt8(b *testing.B) { + data := &ValidGenLteInt8Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteInt8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteInt8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteInt8Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteInt16(b *testing.B) { + data := &ValidGenLteInt16Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteInt16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteInt16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteInt16Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteInt32(b *testing.B) { + data := &ValidGenLteInt32Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteInt32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteInt32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteInt32Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteInt64(b *testing.B) { + data := &ValidGenLteInt64Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteInt64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteInt64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteInt64Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUint(b *testing.B) { + data := &ValidGenLteUintStruct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteUintStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUint(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteUintStruct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUint8(b *testing.B) { + data := &ValidGenLteUint8Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteUint8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUint8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteUint8Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUint16(b *testing.B) { + data := &ValidGenLteUint16Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteUint16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUint16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteUint16Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUint32(b *testing.B) { + data := &ValidGenLteUint32Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteUint32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUint32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteUint32Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUint64(b *testing.B) { + data := &ValidGenLteUint64Struct{ + Field: 32, + } + + for b.Loop() { + if err := ValidGenLteUint64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUint64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteUint64Struct{ + Field: 32, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteFloat32(b *testing.B) { + data := &ValidGenLteFloat32Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := ValidGenLteFloat32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteFloat32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteFloat32Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteFloat64(b *testing.B) { + data := &ValidGenLteFloat64Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := ValidGenLteFloat64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteFloat64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLteFloat64Struct{ + Field: 12.34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinString(b *testing.B) { + data := &ValidGenMinStringStruct{ + Field: "abcde", + } + + for b.Loop() { + if err := ValidGenMinStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinStringStruct{ + Field: "abcde", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinStringSlice(b *testing.B) { + data := &ValidGenMinStringSliceStruct{ + Field: []string{"abc", "def"}, + } + + for b.Loop() { + if err := ValidGenMinStringSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinStringSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinStringSliceStruct{ + Field: []string{"abc", "def"}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinIntSlice(b *testing.B) { + data := &ValidGenMinIntSliceStruct{ + Field: []int{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinIntSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinIntSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinIntSliceStruct{ + Field: []int{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt8Slice(b *testing.B) { + data := &ValidGenMinInt8SliceStruct{ + Field: []int8{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinInt8SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt8Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinInt8SliceStruct{ + Field: []int8{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt16Slice(b *testing.B) { + data := &ValidGenMinInt16SliceStruct{ + Field: []int16{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinInt16SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt16Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinInt16SliceStruct{ + Field: []int16{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt32Slice(b *testing.B) { + data := &ValidGenMinInt32SliceStruct{ + Field: []int32{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinInt32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinInt32SliceStruct{ + Field: []int32{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt64Slice(b *testing.B) { + data := &ValidGenMinInt64SliceStruct{ + Field: []int64{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinInt64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinInt64SliceStruct{ + Field: []int64{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUintSlice(b *testing.B) { + data := &ValidGenMinUintSliceStruct{ + Field: []uint{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinUintSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUintSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUintSliceStruct{ + Field: []uint{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint8Slice(b *testing.B) { + data := &ValidGenMinUint8SliceStruct{ + Field: []uint8{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinUint8SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint8Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUint8SliceStruct{ + Field: []uint8{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint16Slice(b *testing.B) { + data := &ValidGenMinUint16SliceStruct{ + Field: []uint16{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinUint16SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint16Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUint16SliceStruct{ + Field: []uint16{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint32Slice(b *testing.B) { + data := &ValidGenMinUint32SliceStruct{ + Field: []uint32{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinUint32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUint32SliceStruct{ + Field: []uint32{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint64Slice(b *testing.B) { + data := &ValidGenMinUint64SliceStruct{ + Field: []uint64{65, 67}, + } + + for b.Loop() { + if err := ValidGenMinUint64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUint64SliceStruct{ + Field: []uint64{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinFloat32Slice(b *testing.B) { + data := &ValidGenMinFloat32SliceStruct{ + Field: []float32{65.65, 67.67}, + } + + for b.Loop() { + if err := ValidGenMinFloat32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinFloat32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinFloat32SliceStruct{ + Field: []float32{65.65, 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinFloat64Slice(b *testing.B) { + data := &ValidGenMinFloat64SliceStruct{ + Field: []float64{65.65, 67.67}, + } + + for b.Loop() { + if err := ValidGenMinFloat64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinFloat64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinFloat64SliceStruct{ + Field: []float64{65.65, 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinBoolSlice(b *testing.B) { + data := &ValidGenMinBoolSliceStruct{ + Field: []bool{true, false}, + } + + for b.Loop() { + if err := ValidGenMinBoolSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinBoolSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinBoolSliceStruct{ + Field: []bool{true, false}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinStringMap(b *testing.B) { + data := &ValidGenMinStringMapStruct{ + Field: map[string]string{"a": "1", "b": "2"}, + } + + for b.Loop() { + if err := ValidGenMinStringMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinStringMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinStringMapStruct{ + Field: map[string]string{"a": "1", "b": "2"}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinIntMap(b *testing.B) { + data := &ValidGenMinIntMapStruct{ + Field: map[int]int{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinIntMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinIntMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinIntMapStruct{ + Field: map[int]int{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt8Map(b *testing.B) { + data := &ValidGenMinInt8MapStruct{ + Field: map[int8]int8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinInt8MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt8Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinInt8MapStruct{ + Field: map[int8]int8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt16Map(b *testing.B) { + data := &ValidGenMinInt16MapStruct{ + Field: map[int16]int16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinInt16MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt16Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinInt16MapStruct{ + Field: map[int16]int16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt32Map(b *testing.B) { + data := &ValidGenMinInt32MapStruct{ + Field: map[int32]int32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinInt32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinInt32MapStruct{ + Field: map[int32]int32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt64Map(b *testing.B) { + data := &ValidGenMinInt64MapStruct{ + Field: map[int64]int64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinInt64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinInt64MapStruct{ + Field: map[int64]int64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUintMap(b *testing.B) { + data := &ValidGenMinUintMapStruct{ + Field: map[uint]uint{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinUintMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUintMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUintMapStruct{ + Field: map[uint]uint{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint8Map(b *testing.B) { + data := &ValidGenMinUint8MapStruct{ + Field: map[uint8]uint8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinUint8MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint8Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUint8MapStruct{ + Field: map[uint8]uint8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint16Map(b *testing.B) { + data := &ValidGenMinUint16MapStruct{ + Field: map[uint16]uint16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinUint16MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint16Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUint16MapStruct{ + Field: map[uint16]uint16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint32Map(b *testing.B) { + data := &ValidGenMinUint32MapStruct{ + Field: map[uint32]uint32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinUint32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUint32MapStruct{ + Field: map[uint32]uint32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint64Map(b *testing.B) { + data := &ValidGenMinUint64MapStruct{ + Field: map[uint64]uint64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMinUint64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinUint64MapStruct{ + Field: map[uint64]uint64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinFloat32Map(b *testing.B) { + data := &ValidGenMinFloat32MapStruct{ + Field: map[float32]float32{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := ValidGenMinFloat32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinFloat32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinFloat32MapStruct{ + Field: map[float32]float32{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinFloat64Map(b *testing.B) { + data := &ValidGenMinFloat64MapStruct{ + Field: map[float64]float64{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := ValidGenMinFloat64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinFloat64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinFloat64MapStruct{ + Field: map[float64]float64{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinBoolMap(b *testing.B) { + data := &ValidGenMinBoolMapStruct{ + Field: map[bool]bool{true: true, false: false}, + } + + for b.Loop() { + if err := ValidGenMinBoolMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinBoolMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMinBoolMapStruct{ + Field: map[bool]bool{true: true, false: false}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxString(b *testing.B) { + data := &ValidGenMaxStringStruct{ + Field: "abc", + } + + for b.Loop() { + if err := ValidGenMaxStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxStringStruct{ + Field: "abc", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxStringSlice(b *testing.B) { + data := &ValidGenMaxStringSliceStruct{ + Field: []string{"abc", "def"}, + } + + for b.Loop() { + if err := ValidGenMaxStringSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxStringSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxStringSliceStruct{ + Field: []string{"abc", "def"}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxIntSlice(b *testing.B) { + data := &ValidGenMaxIntSliceStruct{ + Field: []int{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxIntSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxIntSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxIntSliceStruct{ + Field: []int{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt8Slice(b *testing.B) { + data := &ValidGenMaxInt8SliceStruct{ + Field: []int8{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxInt8SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt8Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxInt8SliceStruct{ + Field: []int8{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt16Slice(b *testing.B) { + data := &ValidGenMaxInt16SliceStruct{ + Field: []int16{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxInt16SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt16Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxInt16SliceStruct{ + Field: []int16{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt32Slice(b *testing.B) { + data := &ValidGenMaxInt32SliceStruct{ + Field: []int32{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxInt32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxInt32SliceStruct{ + Field: []int32{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt64Slice(b *testing.B) { + data := &ValidGenMaxInt64SliceStruct{ + Field: []int64{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxInt64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxInt64SliceStruct{ + Field: []int64{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUintSlice(b *testing.B) { + data := &ValidGenMaxUintSliceStruct{ + Field: []uint{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxUintSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUintSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUintSliceStruct{ + Field: []uint{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint8Slice(b *testing.B) { + data := &ValidGenMaxUint8SliceStruct{ + Field: []uint8{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxUint8SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint8Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUint8SliceStruct{ + Field: []uint8{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint16Slice(b *testing.B) { + data := &ValidGenMaxUint16SliceStruct{ + Field: []uint16{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxUint16SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint16Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUint16SliceStruct{ + Field: []uint16{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint32Slice(b *testing.B) { + data := &ValidGenMaxUint32SliceStruct{ + Field: []uint32{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxUint32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUint32SliceStruct{ + Field: []uint32{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint64Slice(b *testing.B) { + data := &ValidGenMaxUint64SliceStruct{ + Field: []uint64{65, 67}, + } + + for b.Loop() { + if err := ValidGenMaxUint64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUint64SliceStruct{ + Field: []uint64{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxFloat32Slice(b *testing.B) { + data := &ValidGenMaxFloat32SliceStruct{ + Field: []float32{65.65, 67.67}, + } + + for b.Loop() { + if err := ValidGenMaxFloat32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxFloat32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxFloat32SliceStruct{ + Field: []float32{65.65, 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxFloat64Slice(b *testing.B) { + data := &ValidGenMaxFloat64SliceStruct{ + Field: []float64{65.65, 67.67}, + } + + for b.Loop() { + if err := ValidGenMaxFloat64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxFloat64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxFloat64SliceStruct{ + Field: []float64{65.65, 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxBoolSlice(b *testing.B) { + data := &ValidGenMaxBoolSliceStruct{ + Field: []bool{true, false}, + } + + for b.Loop() { + if err := ValidGenMaxBoolSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxBoolSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxBoolSliceStruct{ + Field: []bool{true, false}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxStringMap(b *testing.B) { + data := &ValidGenMaxStringMapStruct{ + Field: map[string]string{"a": "1", "b": "2"}, + } + + for b.Loop() { + if err := ValidGenMaxStringMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxStringMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxStringMapStruct{ + Field: map[string]string{"a": "1", "b": "2"}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxIntMap(b *testing.B) { + data := &ValidGenMaxIntMapStruct{ + Field: map[int]int{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxIntMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxIntMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxIntMapStruct{ + Field: map[int]int{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt8Map(b *testing.B) { + data := &ValidGenMaxInt8MapStruct{ + Field: map[int8]int8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxInt8MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt8Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxInt8MapStruct{ + Field: map[int8]int8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt16Map(b *testing.B) { + data := &ValidGenMaxInt16MapStruct{ + Field: map[int16]int16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxInt16MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt16Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxInt16MapStruct{ + Field: map[int16]int16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt32Map(b *testing.B) { + data := &ValidGenMaxInt32MapStruct{ + Field: map[int32]int32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxInt32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxInt32MapStruct{ + Field: map[int32]int32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt64Map(b *testing.B) { + data := &ValidGenMaxInt64MapStruct{ + Field: map[int64]int64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxInt64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxInt64MapStruct{ + Field: map[int64]int64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUintMap(b *testing.B) { + data := &ValidGenMaxUintMapStruct{ + Field: map[uint]uint{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxUintMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUintMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUintMapStruct{ + Field: map[uint]uint{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint8Map(b *testing.B) { + data := &ValidGenMaxUint8MapStruct{ + Field: map[uint8]uint8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxUint8MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint8Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUint8MapStruct{ + Field: map[uint8]uint8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint16Map(b *testing.B) { + data := &ValidGenMaxUint16MapStruct{ + Field: map[uint16]uint16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxUint16MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint16Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUint16MapStruct{ + Field: map[uint16]uint16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint32Map(b *testing.B) { + data := &ValidGenMaxUint32MapStruct{ + Field: map[uint32]uint32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxUint32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUint32MapStruct{ + Field: map[uint32]uint32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint64Map(b *testing.B) { + data := &ValidGenMaxUint64MapStruct{ + Field: map[uint64]uint64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenMaxUint64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxUint64MapStruct{ + Field: map[uint64]uint64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxFloat32Map(b *testing.B) { + data := &ValidGenMaxFloat32MapStruct{ + Field: map[float32]float32{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := ValidGenMaxFloat32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxFloat32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxFloat32MapStruct{ + Field: map[float32]float32{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxFloat64Map(b *testing.B) { + data := &ValidGenMaxFloat64MapStruct{ + Field: map[float64]float64{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := ValidGenMaxFloat64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxFloat64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxFloat64MapStruct{ + Field: map[float64]float64{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxBoolMap(b *testing.B) { + data := &ValidGenMaxBoolMapStruct{ + Field: map[bool]bool{true: true}, + } + + for b.Loop() { + if err := ValidGenMaxBoolMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxBoolMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorMaxBoolMapStruct{ + Field: map[bool]bool{true: true}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEq_ignore_caseString(b *testing.B) { + data := &ValidGenEq_ignore_caseStringStruct{ + Field: "AbCdE", + } + + for b.Loop() { + if err := ValidGenEq_ignore_caseStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEq_ignore_caseString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorEq_ignore_caseStringStruct{ + Field: "AbCdE", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeq_ignore_caseString(b *testing.B) { + data := &ValidGenNeq_ignore_caseStringStruct{ + Field: "a1b2c3", + } + + for b.Loop() { + if err := ValidGenNeq_ignore_caseStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeq_ignore_caseString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorNeq_ignore_caseStringStruct{ + Field: "a1b2c3", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenString(b *testing.B) { + data := &ValidGenLenStringStruct{ + Field: "ab", + } + + for b.Loop() { + if err := ValidGenLenStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenStringStruct{ + Field: "ab", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenStringSlice(b *testing.B) { + data := &ValidGenLenStringSliceStruct{ + Field: []string{"abc", "def"}, + } + + for b.Loop() { + if err := ValidGenLenStringSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenStringSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenStringSliceStruct{ + Field: []string{"abc", "def"}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenIntSlice(b *testing.B) { + data := &ValidGenLenIntSliceStruct{ + Field: []int{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenIntSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenIntSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenIntSliceStruct{ + Field: []int{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt8Slice(b *testing.B) { + data := &ValidGenLenInt8SliceStruct{ + Field: []int8{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenInt8SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt8Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenInt8SliceStruct{ + Field: []int8{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt16Slice(b *testing.B) { + data := &ValidGenLenInt16SliceStruct{ + Field: []int16{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenInt16SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt16Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenInt16SliceStruct{ + Field: []int16{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt32Slice(b *testing.B) { + data := &ValidGenLenInt32SliceStruct{ + Field: []int32{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenInt32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenInt32SliceStruct{ + Field: []int32{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt64Slice(b *testing.B) { + data := &ValidGenLenInt64SliceStruct{ + Field: []int64{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenInt64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenInt64SliceStruct{ + Field: []int64{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUintSlice(b *testing.B) { + data := &ValidGenLenUintSliceStruct{ + Field: []uint{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenUintSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUintSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUintSliceStruct{ + Field: []uint{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint8Slice(b *testing.B) { + data := &ValidGenLenUint8SliceStruct{ + Field: []uint8{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenUint8SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint8Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUint8SliceStruct{ + Field: []uint8{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint16Slice(b *testing.B) { + data := &ValidGenLenUint16SliceStruct{ + Field: []uint16{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenUint16SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint16Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUint16SliceStruct{ + Field: []uint16{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint32Slice(b *testing.B) { + data := &ValidGenLenUint32SliceStruct{ + Field: []uint32{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenUint32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUint32SliceStruct{ + Field: []uint32{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint64Slice(b *testing.B) { + data := &ValidGenLenUint64SliceStruct{ + Field: []uint64{65, 67}, + } + + for b.Loop() { + if err := ValidGenLenUint64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUint64SliceStruct{ + Field: []uint64{65, 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenFloat32Slice(b *testing.B) { + data := &ValidGenLenFloat32SliceStruct{ + Field: []float32{65.65, 67.67}, + } + + for b.Loop() { + if err := ValidGenLenFloat32SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenFloat32Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenFloat32SliceStruct{ + Field: []float32{65.65, 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenFloat64Slice(b *testing.B) { + data := &ValidGenLenFloat64SliceStruct{ + Field: []float64{65.65, 67.67}, + } + + for b.Loop() { + if err := ValidGenLenFloat64SliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenFloat64Slice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenFloat64SliceStruct{ + Field: []float64{65.65, 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenBoolSlice(b *testing.B) { + data := &ValidGenLenBoolSliceStruct{ + Field: []bool{true, false}, + } + + for b.Loop() { + if err := ValidGenLenBoolSliceStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenBoolSlice(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenBoolSliceStruct{ + Field: []bool{true, false}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenStringMap(b *testing.B) { + data := &ValidGenLenStringMapStruct{ + Field: map[string]string{"a": "1", "b": "2"}, + } + + for b.Loop() { + if err := ValidGenLenStringMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenStringMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenStringMapStruct{ + Field: map[string]string{"a": "1", "b": "2"}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenIntMap(b *testing.B) { + data := &ValidGenLenIntMapStruct{ + Field: map[int]int{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenIntMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenIntMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenIntMapStruct{ + Field: map[int]int{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt8Map(b *testing.B) { + data := &ValidGenLenInt8MapStruct{ + Field: map[int8]int8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenInt8MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt8Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenInt8MapStruct{ + Field: map[int8]int8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt16Map(b *testing.B) { + data := &ValidGenLenInt16MapStruct{ + Field: map[int16]int16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenInt16MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt16Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenInt16MapStruct{ + Field: map[int16]int16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt32Map(b *testing.B) { + data := &ValidGenLenInt32MapStruct{ + Field: map[int32]int32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenInt32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenInt32MapStruct{ + Field: map[int32]int32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt64Map(b *testing.B) { + data := &ValidGenLenInt64MapStruct{ + Field: map[int64]int64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenInt64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenInt64MapStruct{ + Field: map[int64]int64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUintMap(b *testing.B) { + data := &ValidGenLenUintMapStruct{ + Field: map[uint]uint{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenUintMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUintMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUintMapStruct{ + Field: map[uint]uint{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint8Map(b *testing.B) { + data := &ValidGenLenUint8MapStruct{ + Field: map[uint8]uint8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenUint8MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint8Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUint8MapStruct{ + Field: map[uint8]uint8{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint16Map(b *testing.B) { + data := &ValidGenLenUint16MapStruct{ + Field: map[uint16]uint16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenUint16MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint16Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUint16MapStruct{ + Field: map[uint16]uint16{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint32Map(b *testing.B) { + data := &ValidGenLenUint32MapStruct{ + Field: map[uint32]uint32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenUint32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUint32MapStruct{ + Field: map[uint32]uint32{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint64Map(b *testing.B) { + data := &ValidGenLenUint64MapStruct{ + Field: map[uint64]uint64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := ValidGenLenUint64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenUint64MapStruct{ + Field: map[uint64]uint64{1: 65, 2: 67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenFloat32Map(b *testing.B) { + data := &ValidGenLenFloat32MapStruct{ + Field: map[float32]float32{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := ValidGenLenFloat32MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenFloat32Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenFloat32MapStruct{ + Field: map[float32]float32{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenFloat64Map(b *testing.B) { + data := &ValidGenLenFloat64MapStruct{ + Field: map[float64]float64{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := ValidGenLenFloat64MapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenFloat64Map(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenFloat64MapStruct{ + Field: map[float64]float64{1: 65.65, 2: 67.67}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenBoolMap(b *testing.B) { + data := &ValidGenLenBoolMapStruct{ + Field: map[bool]bool{true: true, false: false}, + } + + for b.Loop() { + if err := ValidGenLenBoolMapStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenBoolMap(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorLenBoolMapStruct{ + Field: map[bool]bool{true: true, false: false}, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInString(b *testing.B) { + data := &ValidGenInStringStruct{ + Field: "cd", + } + + for b.Loop() { + if err := ValidGenInStringStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInString(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInStringStruct{ + Field: "cd", + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInInt(b *testing.B) { + data := &ValidGenInIntStruct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInIntStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInInt(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInIntStruct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInInt8(b *testing.B) { + data := &ValidGenInInt8Struct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInInt8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInInt8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInInt8Struct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInInt16(b *testing.B) { + data := &ValidGenInInt16Struct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInInt16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInInt16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInInt16Struct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInInt32(b *testing.B) { + data := &ValidGenInInt32Struct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInInt32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInInt32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInInt32Struct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInInt64(b *testing.B) { + data := &ValidGenInInt64Struct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInInt64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInInt64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInInt64Struct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUint(b *testing.B) { + data := &ValidGenInUintStruct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInUintStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUint(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInUintStruct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUint8(b *testing.B) { + data := &ValidGenInUint8Struct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInUint8StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUint8(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInUint8Struct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUint16(b *testing.B) { + data := &ValidGenInUint16Struct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInUint16StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUint16(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInUint16Struct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUint32(b *testing.B) { + data := &ValidGenInUint32Struct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInUint32StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUint32(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInUint32Struct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUint64(b *testing.B) { + data := &ValidGenInUint64Struct{ + Field: 34, + } + + for b.Loop() { + if err := ValidGenInUint64StructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUint64(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + data := &ValidatorInUint64Struct{ + Field: 34, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} diff --git a/tests/cmpbenchtests/generated_tests/generated_cmp_perf_pointer_test.go b/tests/cmpbenchtests/generated_tests/generated_cmp_perf_pointer_test.go new file mode 100644 index 0000000..7418317 --- /dev/null +++ b/tests/cmpbenchtests/generated_tests/generated_cmp_perf_pointer_test.go @@ -0,0 +1,9096 @@ +// Code generated by TestGen. DO NOT EDIT. + +package benchtests + +import ( + "testing" + + "github.com/go-playground/validator/v10" +) + +type ValidGenEmailStringPointerStruct struct { + Field *string `valid:"email"` +} + +type ValidatorEmailStringPointerStruct struct { + Field *string `validate:"email"` +} + +type ValidGenRequiredStringPointerStruct struct { + Field *string `valid:"required"` +} + +type ValidatorRequiredStringPointerStruct struct { + Field *string `validate:"required"` +} + +type ValidGenRequiredIntPointerStruct struct { + Field *int `valid:"required"` +} + +type ValidatorRequiredIntPointerStruct struct { + Field *int `validate:"required"` +} + +type ValidGenRequiredInt8PointerStruct struct { + Field *int8 `valid:"required"` +} + +type ValidatorRequiredInt8PointerStruct struct { + Field *int8 `validate:"required"` +} + +type ValidGenRequiredInt16PointerStruct struct { + Field *int16 `valid:"required"` +} + +type ValidatorRequiredInt16PointerStruct struct { + Field *int16 `validate:"required"` +} + +type ValidGenRequiredInt32PointerStruct struct { + Field *int32 `valid:"required"` +} + +type ValidatorRequiredInt32PointerStruct struct { + Field *int32 `validate:"required"` +} + +type ValidGenRequiredInt64PointerStruct struct { + Field *int64 `valid:"required"` +} + +type ValidatorRequiredInt64PointerStruct struct { + Field *int64 `validate:"required"` +} + +type ValidGenRequiredUintPointerStruct struct { + Field *uint `valid:"required"` +} + +type ValidatorRequiredUintPointerStruct struct { + Field *uint `validate:"required"` +} + +type ValidGenRequiredUint8PointerStruct struct { + Field *uint8 `valid:"required"` +} + +type ValidatorRequiredUint8PointerStruct struct { + Field *uint8 `validate:"required"` +} + +type ValidGenRequiredUint16PointerStruct struct { + Field *uint16 `valid:"required"` +} + +type ValidatorRequiredUint16PointerStruct struct { + Field *uint16 `validate:"required"` +} + +type ValidGenRequiredUint32PointerStruct struct { + Field *uint32 `valid:"required"` +} + +type ValidatorRequiredUint32PointerStruct struct { + Field *uint32 `validate:"required"` +} + +type ValidGenRequiredUint64PointerStruct struct { + Field *uint64 `valid:"required"` +} + +type ValidatorRequiredUint64PointerStruct struct { + Field *uint64 `validate:"required"` +} + +type ValidGenRequiredFloat32PointerStruct struct { + Field *float32 `valid:"required"` +} + +type ValidatorRequiredFloat32PointerStruct struct { + Field *float32 `validate:"required"` +} + +type ValidGenRequiredFloat64PointerStruct struct { + Field *float64 `valid:"required"` +} + +type ValidatorRequiredFloat64PointerStruct struct { + Field *float64 `validate:"required"` +} + +type ValidGenRequiredBoolPointerStruct struct { + Field *bool `valid:"required"` +} + +type ValidatorRequiredBoolPointerStruct struct { + Field *bool `validate:"required"` +} + +type ValidGenRequiredStringSlicePointerStruct struct { + Field *[]string `valid:"required"` +} + +type ValidatorRequiredStringSlicePointerStruct struct { + Field *[]string `validate:"required"` +} + +type ValidGenRequiredIntSlicePointerStruct struct { + Field *[]int `valid:"required"` +} + +type ValidatorRequiredIntSlicePointerStruct struct { + Field *[]int `validate:"required"` +} + +type ValidGenRequiredInt8SlicePointerStruct struct { + Field *[]int8 `valid:"required"` +} + +type ValidatorRequiredInt8SlicePointerStruct struct { + Field *[]int8 `validate:"required"` +} + +type ValidGenRequiredInt16SlicePointerStruct struct { + Field *[]int16 `valid:"required"` +} + +type ValidatorRequiredInt16SlicePointerStruct struct { + Field *[]int16 `validate:"required"` +} + +type ValidGenRequiredInt32SlicePointerStruct struct { + Field *[]int32 `valid:"required"` +} + +type ValidatorRequiredInt32SlicePointerStruct struct { + Field *[]int32 `validate:"required"` +} + +type ValidGenRequiredInt64SlicePointerStruct struct { + Field *[]int64 `valid:"required"` +} + +type ValidatorRequiredInt64SlicePointerStruct struct { + Field *[]int64 `validate:"required"` +} + +type ValidGenRequiredUintSlicePointerStruct struct { + Field *[]uint `valid:"required"` +} + +type ValidatorRequiredUintSlicePointerStruct struct { + Field *[]uint `validate:"required"` +} + +type ValidGenRequiredUint8SlicePointerStruct struct { + Field *[]uint8 `valid:"required"` +} + +type ValidatorRequiredUint8SlicePointerStruct struct { + Field *[]uint8 `validate:"required"` +} + +type ValidGenRequiredUint16SlicePointerStruct struct { + Field *[]uint16 `valid:"required"` +} + +type ValidatorRequiredUint16SlicePointerStruct struct { + Field *[]uint16 `validate:"required"` +} + +type ValidGenRequiredUint32SlicePointerStruct struct { + Field *[]uint32 `valid:"required"` +} + +type ValidatorRequiredUint32SlicePointerStruct struct { + Field *[]uint32 `validate:"required"` +} + +type ValidGenRequiredUint64SlicePointerStruct struct { + Field *[]uint64 `valid:"required"` +} + +type ValidatorRequiredUint64SlicePointerStruct struct { + Field *[]uint64 `validate:"required"` +} + +type ValidGenRequiredFloat32SlicePointerStruct struct { + Field *[]float32 `valid:"required"` +} + +type ValidatorRequiredFloat32SlicePointerStruct struct { + Field *[]float32 `validate:"required"` +} + +type ValidGenRequiredFloat64SlicePointerStruct struct { + Field *[]float64 `valid:"required"` +} + +type ValidatorRequiredFloat64SlicePointerStruct struct { + Field *[]float64 `validate:"required"` +} + +type ValidGenRequiredBoolSlicePointerStruct struct { + Field *[]bool `valid:"required"` +} + +type ValidatorRequiredBoolSlicePointerStruct struct { + Field *[]bool `validate:"required"` +} + +type ValidGenRequiredStringArrayPointerStruct struct { + Field *[3]string `valid:"required"` +} + +type ValidatorRequiredStringArrayPointerStruct struct { + Field *[3]string `validate:"required"` +} + +type ValidGenRequiredIntArrayPointerStruct struct { + Field *[3]int `valid:"required"` +} + +type ValidatorRequiredIntArrayPointerStruct struct { + Field *[3]int `validate:"required"` +} + +type ValidGenRequiredInt8ArrayPointerStruct struct { + Field *[3]int8 `valid:"required"` +} + +type ValidatorRequiredInt8ArrayPointerStruct struct { + Field *[3]int8 `validate:"required"` +} + +type ValidGenRequiredInt16ArrayPointerStruct struct { + Field *[3]int16 `valid:"required"` +} + +type ValidatorRequiredInt16ArrayPointerStruct struct { + Field *[3]int16 `validate:"required"` +} + +type ValidGenRequiredInt32ArrayPointerStruct struct { + Field *[3]int32 `valid:"required"` +} + +type ValidatorRequiredInt32ArrayPointerStruct struct { + Field *[3]int32 `validate:"required"` +} + +type ValidGenRequiredInt64ArrayPointerStruct struct { + Field *[3]int64 `valid:"required"` +} + +type ValidatorRequiredInt64ArrayPointerStruct struct { + Field *[3]int64 `validate:"required"` +} + +type ValidGenRequiredUintArrayPointerStruct struct { + Field *[3]uint `valid:"required"` +} + +type ValidatorRequiredUintArrayPointerStruct struct { + Field *[3]uint `validate:"required"` +} + +type ValidGenRequiredUint8ArrayPointerStruct struct { + Field *[3]uint8 `valid:"required"` +} + +type ValidatorRequiredUint8ArrayPointerStruct struct { + Field *[3]uint8 `validate:"required"` +} + +type ValidGenRequiredUint16ArrayPointerStruct struct { + Field *[3]uint16 `valid:"required"` +} + +type ValidatorRequiredUint16ArrayPointerStruct struct { + Field *[3]uint16 `validate:"required"` +} + +type ValidGenRequiredUint32ArrayPointerStruct struct { + Field *[3]uint32 `valid:"required"` +} + +type ValidatorRequiredUint32ArrayPointerStruct struct { + Field *[3]uint32 `validate:"required"` +} + +type ValidGenRequiredUint64ArrayPointerStruct struct { + Field *[3]uint64 `valid:"required"` +} + +type ValidatorRequiredUint64ArrayPointerStruct struct { + Field *[3]uint64 `validate:"required"` +} + +type ValidGenRequiredFloat32ArrayPointerStruct struct { + Field *[3]float32 `valid:"required"` +} + +type ValidatorRequiredFloat32ArrayPointerStruct struct { + Field *[3]float32 `validate:"required"` +} + +type ValidGenRequiredFloat64ArrayPointerStruct struct { + Field *[3]float64 `valid:"required"` +} + +type ValidatorRequiredFloat64ArrayPointerStruct struct { + Field *[3]float64 `validate:"required"` +} + +type ValidGenRequiredBoolArrayPointerStruct struct { + Field *[3]bool `valid:"required"` +} + +type ValidatorRequiredBoolArrayPointerStruct struct { + Field *[3]bool `validate:"required"` +} + +type ValidGenRequiredStringMapPointerStruct struct { + Field *map[string]string `valid:"required"` +} + +type ValidatorRequiredStringMapPointerStruct struct { + Field *map[string]string `validate:"required"` +} + +type ValidGenRequiredIntMapPointerStruct struct { + Field *map[int]int `valid:"required"` +} + +type ValidatorRequiredIntMapPointerStruct struct { + Field *map[int]int `validate:"required"` +} + +type ValidGenRequiredInt8MapPointerStruct struct { + Field *map[int8]int8 `valid:"required"` +} + +type ValidatorRequiredInt8MapPointerStruct struct { + Field *map[int8]int8 `validate:"required"` +} + +type ValidGenRequiredInt16MapPointerStruct struct { + Field *map[int16]int16 `valid:"required"` +} + +type ValidatorRequiredInt16MapPointerStruct struct { + Field *map[int16]int16 `validate:"required"` +} + +type ValidGenRequiredInt32MapPointerStruct struct { + Field *map[int32]int32 `valid:"required"` +} + +type ValidatorRequiredInt32MapPointerStruct struct { + Field *map[int32]int32 `validate:"required"` +} + +type ValidGenRequiredInt64MapPointerStruct struct { + Field *map[int64]int64 `valid:"required"` +} + +type ValidatorRequiredInt64MapPointerStruct struct { + Field *map[int64]int64 `validate:"required"` +} + +type ValidGenRequiredUintMapPointerStruct struct { + Field *map[uint]uint `valid:"required"` +} + +type ValidatorRequiredUintMapPointerStruct struct { + Field *map[uint]uint `validate:"required"` +} + +type ValidGenRequiredUint8MapPointerStruct struct { + Field *map[uint8]uint8 `valid:"required"` +} + +type ValidatorRequiredUint8MapPointerStruct struct { + Field *map[uint8]uint8 `validate:"required"` +} + +type ValidGenRequiredUint16MapPointerStruct struct { + Field *map[uint16]uint16 `valid:"required"` +} + +type ValidatorRequiredUint16MapPointerStruct struct { + Field *map[uint16]uint16 `validate:"required"` +} + +type ValidGenRequiredUint32MapPointerStruct struct { + Field *map[uint32]uint32 `valid:"required"` +} + +type ValidatorRequiredUint32MapPointerStruct struct { + Field *map[uint32]uint32 `validate:"required"` +} + +type ValidGenRequiredUint64MapPointerStruct struct { + Field *map[uint64]uint64 `valid:"required"` +} + +type ValidatorRequiredUint64MapPointerStruct struct { + Field *map[uint64]uint64 `validate:"required"` +} + +type ValidGenRequiredFloat32MapPointerStruct struct { + Field *map[float32]float32 `valid:"required"` +} + +type ValidatorRequiredFloat32MapPointerStruct struct { + Field *map[float32]float32 `validate:"required"` +} + +type ValidGenRequiredFloat64MapPointerStruct struct { + Field *map[float64]float64 `valid:"required"` +} + +type ValidatorRequiredFloat64MapPointerStruct struct { + Field *map[float64]float64 `validate:"required"` +} + +type ValidGenRequiredBoolMapPointerStruct struct { + Field *map[bool]bool `valid:"required"` +} + +type ValidatorRequiredBoolMapPointerStruct struct { + Field *map[bool]bool `validate:"required"` +} + +type ValidGenEqStringPointerStruct struct { + Field *string `valid:"eq=abcde"` +} + +type ValidatorEqStringPointerStruct struct { + Field *string `validate:"eq=abcde"` +} + +type ValidGenEqIntPointerStruct struct { + Field *int `valid:"eq=32"` +} + +type ValidatorEqIntPointerStruct struct { + Field *int `validate:"eq=32"` +} + +type ValidGenEqInt8PointerStruct struct { + Field *int8 `valid:"eq=32"` +} + +type ValidatorEqInt8PointerStruct struct { + Field *int8 `validate:"eq=32"` +} + +type ValidGenEqInt16PointerStruct struct { + Field *int16 `valid:"eq=32"` +} + +type ValidatorEqInt16PointerStruct struct { + Field *int16 `validate:"eq=32"` +} + +type ValidGenEqInt32PointerStruct struct { + Field *int32 `valid:"eq=32"` +} + +type ValidatorEqInt32PointerStruct struct { + Field *int32 `validate:"eq=32"` +} + +type ValidGenEqInt64PointerStruct struct { + Field *int64 `valid:"eq=32"` +} + +type ValidatorEqInt64PointerStruct struct { + Field *int64 `validate:"eq=32"` +} + +type ValidGenEqUintPointerStruct struct { + Field *uint `valid:"eq=32"` +} + +type ValidatorEqUintPointerStruct struct { + Field *uint `validate:"eq=32"` +} + +type ValidGenEqUint8PointerStruct struct { + Field *uint8 `valid:"eq=32"` +} + +type ValidatorEqUint8PointerStruct struct { + Field *uint8 `validate:"eq=32"` +} + +type ValidGenEqUint16PointerStruct struct { + Field *uint16 `valid:"eq=32"` +} + +type ValidatorEqUint16PointerStruct struct { + Field *uint16 `validate:"eq=32"` +} + +type ValidGenEqUint32PointerStruct struct { + Field *uint32 `valid:"eq=32"` +} + +type ValidatorEqUint32PointerStruct struct { + Field *uint32 `validate:"eq=32"` +} + +type ValidGenEqUint64PointerStruct struct { + Field *uint64 `valid:"eq=32"` +} + +type ValidatorEqUint64PointerStruct struct { + Field *uint64 `validate:"eq=32"` +} + +type ValidGenEqFloat32PointerStruct struct { + Field *float32 `valid:"eq=12.34"` +} + +type ValidatorEqFloat32PointerStruct struct { + Field *float32 `validate:"eq=12.34"` +} + +type ValidGenEqFloat64PointerStruct struct { + Field *float64 `valid:"eq=12.34"` +} + +type ValidatorEqFloat64PointerStruct struct { + Field *float64 `validate:"eq=12.34"` +} + +type ValidGenEqBoolPointerStruct struct { + Field *bool `valid:"eq=true"` +} + +type ValidatorEqBoolPointerStruct struct { + Field *bool `validate:"eq=true"` +} + +type ValidGenNeqStringPointerStruct struct { + Field *string `valid:"neq=abcde"` +} + +type ValidatorNeqStringPointerStruct struct { + Field *string `validate:"ne=abcde"` +} + +type ValidGenNeqIntPointerStruct struct { + Field *int `valid:"neq=32"` +} + +type ValidatorNeqIntPointerStruct struct { + Field *int `validate:"ne=32"` +} + +type ValidGenNeqInt8PointerStruct struct { + Field *int8 `valid:"neq=32"` +} + +type ValidatorNeqInt8PointerStruct struct { + Field *int8 `validate:"ne=32"` +} + +type ValidGenNeqInt16PointerStruct struct { + Field *int16 `valid:"neq=32"` +} + +type ValidatorNeqInt16PointerStruct struct { + Field *int16 `validate:"ne=32"` +} + +type ValidGenNeqInt32PointerStruct struct { + Field *int32 `valid:"neq=32"` +} + +type ValidatorNeqInt32PointerStruct struct { + Field *int32 `validate:"ne=32"` +} + +type ValidGenNeqInt64PointerStruct struct { + Field *int64 `valid:"neq=32"` +} + +type ValidatorNeqInt64PointerStruct struct { + Field *int64 `validate:"ne=32"` +} + +type ValidGenNeqUintPointerStruct struct { + Field *uint `valid:"neq=32"` +} + +type ValidatorNeqUintPointerStruct struct { + Field *uint `validate:"ne=32"` +} + +type ValidGenNeqUint8PointerStruct struct { + Field *uint8 `valid:"neq=32"` +} + +type ValidatorNeqUint8PointerStruct struct { + Field *uint8 `validate:"ne=32"` +} + +type ValidGenNeqUint16PointerStruct struct { + Field *uint16 `valid:"neq=32"` +} + +type ValidatorNeqUint16PointerStruct struct { + Field *uint16 `validate:"ne=32"` +} + +type ValidGenNeqUint32PointerStruct struct { + Field *uint32 `valid:"neq=32"` +} + +type ValidatorNeqUint32PointerStruct struct { + Field *uint32 `validate:"ne=32"` +} + +type ValidGenNeqUint64PointerStruct struct { + Field *uint64 `valid:"neq=32"` +} + +type ValidatorNeqUint64PointerStruct struct { + Field *uint64 `validate:"ne=32"` +} + +type ValidGenNeqFloat32PointerStruct struct { + Field *float32 `valid:"neq=12.34"` +} + +type ValidatorNeqFloat32PointerStruct struct { + Field *float32 `validate:"ne=12.34"` +} + +type ValidGenNeqFloat64PointerStruct struct { + Field *float64 `valid:"neq=12.34"` +} + +type ValidatorNeqFloat64PointerStruct struct { + Field *float64 `validate:"ne=12.34"` +} + +type ValidGenNeqBoolPointerStruct struct { + Field *bool `valid:"neq=true"` +} + +type ValidatorNeqBoolPointerStruct struct { + Field *bool `validate:"ne=true"` +} + +type ValidGenGtIntPointerStruct struct { + Field *int `valid:"gt=32"` +} + +type ValidatorGtIntPointerStruct struct { + Field *int `validate:"gt=32"` +} + +type ValidGenGtInt8PointerStruct struct { + Field *int8 `valid:"gt=32"` +} + +type ValidatorGtInt8PointerStruct struct { + Field *int8 `validate:"gt=32"` +} + +type ValidGenGtInt16PointerStruct struct { + Field *int16 `valid:"gt=32"` +} + +type ValidatorGtInt16PointerStruct struct { + Field *int16 `validate:"gt=32"` +} + +type ValidGenGtInt32PointerStruct struct { + Field *int32 `valid:"gt=32"` +} + +type ValidatorGtInt32PointerStruct struct { + Field *int32 `validate:"gt=32"` +} + +type ValidGenGtInt64PointerStruct struct { + Field *int64 `valid:"gt=32"` +} + +type ValidatorGtInt64PointerStruct struct { + Field *int64 `validate:"gt=32"` +} + +type ValidGenGtUintPointerStruct struct { + Field *uint `valid:"gt=32"` +} + +type ValidatorGtUintPointerStruct struct { + Field *uint `validate:"gt=32"` +} + +type ValidGenGtUint8PointerStruct struct { + Field *uint8 `valid:"gt=32"` +} + +type ValidatorGtUint8PointerStruct struct { + Field *uint8 `validate:"gt=32"` +} + +type ValidGenGtUint16PointerStruct struct { + Field *uint16 `valid:"gt=32"` +} + +type ValidatorGtUint16PointerStruct struct { + Field *uint16 `validate:"gt=32"` +} + +type ValidGenGtUint32PointerStruct struct { + Field *uint32 `valid:"gt=32"` +} + +type ValidatorGtUint32PointerStruct struct { + Field *uint32 `validate:"gt=32"` +} + +type ValidGenGtUint64PointerStruct struct { + Field *uint64 `valid:"gt=32"` +} + +type ValidatorGtUint64PointerStruct struct { + Field *uint64 `validate:"gt=32"` +} + +type ValidGenGtFloat32PointerStruct struct { + Field *float32 `valid:"gt=12.34"` +} + +type ValidatorGtFloat32PointerStruct struct { + Field *float32 `validate:"gt=12.34"` +} + +type ValidGenGtFloat64PointerStruct struct { + Field *float64 `valid:"gt=12.34"` +} + +type ValidatorGtFloat64PointerStruct struct { + Field *float64 `validate:"gt=12.34"` +} + +type ValidGenGteIntPointerStruct struct { + Field *int `valid:"gte=32"` +} + +type ValidatorGteIntPointerStruct struct { + Field *int `validate:"gte=32"` +} + +type ValidGenGteInt8PointerStruct struct { + Field *int8 `valid:"gte=32"` +} + +type ValidatorGteInt8PointerStruct struct { + Field *int8 `validate:"gte=32"` +} + +type ValidGenGteInt16PointerStruct struct { + Field *int16 `valid:"gte=32"` +} + +type ValidatorGteInt16PointerStruct struct { + Field *int16 `validate:"gte=32"` +} + +type ValidGenGteInt32PointerStruct struct { + Field *int32 `valid:"gte=32"` +} + +type ValidatorGteInt32PointerStruct struct { + Field *int32 `validate:"gte=32"` +} + +type ValidGenGteInt64PointerStruct struct { + Field *int64 `valid:"gte=32"` +} + +type ValidatorGteInt64PointerStruct struct { + Field *int64 `validate:"gte=32"` +} + +type ValidGenGteUintPointerStruct struct { + Field *uint `valid:"gte=32"` +} + +type ValidatorGteUintPointerStruct struct { + Field *uint `validate:"gte=32"` +} + +type ValidGenGteUint8PointerStruct struct { + Field *uint8 `valid:"gte=32"` +} + +type ValidatorGteUint8PointerStruct struct { + Field *uint8 `validate:"gte=32"` +} + +type ValidGenGteUint16PointerStruct struct { + Field *uint16 `valid:"gte=32"` +} + +type ValidatorGteUint16PointerStruct struct { + Field *uint16 `validate:"gte=32"` +} + +type ValidGenGteUint32PointerStruct struct { + Field *uint32 `valid:"gte=32"` +} + +type ValidatorGteUint32PointerStruct struct { + Field *uint32 `validate:"gte=32"` +} + +type ValidGenGteUint64PointerStruct struct { + Field *uint64 `valid:"gte=32"` +} + +type ValidatorGteUint64PointerStruct struct { + Field *uint64 `validate:"gte=32"` +} + +type ValidGenGteFloat32PointerStruct struct { + Field *float32 `valid:"gte=12.34"` +} + +type ValidatorGteFloat32PointerStruct struct { + Field *float32 `validate:"gte=12.34"` +} + +type ValidGenGteFloat64PointerStruct struct { + Field *float64 `valid:"gte=12.34"` +} + +type ValidatorGteFloat64PointerStruct struct { + Field *float64 `validate:"gte=12.34"` +} + +type ValidGenLtIntPointerStruct struct { + Field *int `valid:"lt=32"` +} + +type ValidatorLtIntPointerStruct struct { + Field *int `validate:"lt=32"` +} + +type ValidGenLtInt8PointerStruct struct { + Field *int8 `valid:"lt=32"` +} + +type ValidatorLtInt8PointerStruct struct { + Field *int8 `validate:"lt=32"` +} + +type ValidGenLtInt16PointerStruct struct { + Field *int16 `valid:"lt=32"` +} + +type ValidatorLtInt16PointerStruct struct { + Field *int16 `validate:"lt=32"` +} + +type ValidGenLtInt32PointerStruct struct { + Field *int32 `valid:"lt=32"` +} + +type ValidatorLtInt32PointerStruct struct { + Field *int32 `validate:"lt=32"` +} + +type ValidGenLtInt64PointerStruct struct { + Field *int64 `valid:"lt=32"` +} + +type ValidatorLtInt64PointerStruct struct { + Field *int64 `validate:"lt=32"` +} + +type ValidGenLtUintPointerStruct struct { + Field *uint `valid:"lt=32"` +} + +type ValidatorLtUintPointerStruct struct { + Field *uint `validate:"lt=32"` +} + +type ValidGenLtUint8PointerStruct struct { + Field *uint8 `valid:"lt=32"` +} + +type ValidatorLtUint8PointerStruct struct { + Field *uint8 `validate:"lt=32"` +} + +type ValidGenLtUint16PointerStruct struct { + Field *uint16 `valid:"lt=32"` +} + +type ValidatorLtUint16PointerStruct struct { + Field *uint16 `validate:"lt=32"` +} + +type ValidGenLtUint32PointerStruct struct { + Field *uint32 `valid:"lt=32"` +} + +type ValidatorLtUint32PointerStruct struct { + Field *uint32 `validate:"lt=32"` +} + +type ValidGenLtUint64PointerStruct struct { + Field *uint64 `valid:"lt=32"` +} + +type ValidatorLtUint64PointerStruct struct { + Field *uint64 `validate:"lt=32"` +} + +type ValidGenLtFloat32PointerStruct struct { + Field *float32 `valid:"lt=12.34"` +} + +type ValidatorLtFloat32PointerStruct struct { + Field *float32 `validate:"lt=12.34"` +} + +type ValidGenLtFloat64PointerStruct struct { + Field *float64 `valid:"lt=12.34"` +} + +type ValidatorLtFloat64PointerStruct struct { + Field *float64 `validate:"lt=12.34"` +} + +type ValidGenLteIntPointerStruct struct { + Field *int `valid:"lte=32"` +} + +type ValidatorLteIntPointerStruct struct { + Field *int `validate:"lte=32"` +} + +type ValidGenLteInt8PointerStruct struct { + Field *int8 `valid:"lte=32"` +} + +type ValidatorLteInt8PointerStruct struct { + Field *int8 `validate:"lte=32"` +} + +type ValidGenLteInt16PointerStruct struct { + Field *int16 `valid:"lte=32"` +} + +type ValidatorLteInt16PointerStruct struct { + Field *int16 `validate:"lte=32"` +} + +type ValidGenLteInt32PointerStruct struct { + Field *int32 `valid:"lte=32"` +} + +type ValidatorLteInt32PointerStruct struct { + Field *int32 `validate:"lte=32"` +} + +type ValidGenLteInt64PointerStruct struct { + Field *int64 `valid:"lte=32"` +} + +type ValidatorLteInt64PointerStruct struct { + Field *int64 `validate:"lte=32"` +} + +type ValidGenLteUintPointerStruct struct { + Field *uint `valid:"lte=32"` +} + +type ValidatorLteUintPointerStruct struct { + Field *uint `validate:"lte=32"` +} + +type ValidGenLteUint8PointerStruct struct { + Field *uint8 `valid:"lte=32"` +} + +type ValidatorLteUint8PointerStruct struct { + Field *uint8 `validate:"lte=32"` +} + +type ValidGenLteUint16PointerStruct struct { + Field *uint16 `valid:"lte=32"` +} + +type ValidatorLteUint16PointerStruct struct { + Field *uint16 `validate:"lte=32"` +} + +type ValidGenLteUint32PointerStruct struct { + Field *uint32 `valid:"lte=32"` +} + +type ValidatorLteUint32PointerStruct struct { + Field *uint32 `validate:"lte=32"` +} + +type ValidGenLteUint64PointerStruct struct { + Field *uint64 `valid:"lte=32"` +} + +type ValidatorLteUint64PointerStruct struct { + Field *uint64 `validate:"lte=32"` +} + +type ValidGenLteFloat32PointerStruct struct { + Field *float32 `valid:"lte=12.34"` +} + +type ValidatorLteFloat32PointerStruct struct { + Field *float32 `validate:"lte=12.34"` +} + +type ValidGenLteFloat64PointerStruct struct { + Field *float64 `valid:"lte=12.34"` +} + +type ValidatorLteFloat64PointerStruct struct { + Field *float64 `validate:"lte=12.34"` +} + +type ValidGenMinStringPointerStruct struct { + Field *string `valid:"min=5"` +} + +type ValidatorMinStringPointerStruct struct { + Field *string `validate:"min=5"` +} + +type ValidGenMinStringSlicePointerStruct struct { + Field *[]string `valid:"min=2"` +} + +type ValidatorMinStringSlicePointerStruct struct { + Field *[]string `validate:"min=2"` +} + +type ValidGenMinIntSlicePointerStruct struct { + Field *[]int `valid:"min=2"` +} + +type ValidatorMinIntSlicePointerStruct struct { + Field *[]int `validate:"min=2"` +} + +type ValidGenMinInt8SlicePointerStruct struct { + Field *[]int8 `valid:"min=2"` +} + +type ValidatorMinInt8SlicePointerStruct struct { + Field *[]int8 `validate:"min=2"` +} + +type ValidGenMinInt16SlicePointerStruct struct { + Field *[]int16 `valid:"min=2"` +} + +type ValidatorMinInt16SlicePointerStruct struct { + Field *[]int16 `validate:"min=2"` +} + +type ValidGenMinInt32SlicePointerStruct struct { + Field *[]int32 `valid:"min=2"` +} + +type ValidatorMinInt32SlicePointerStruct struct { + Field *[]int32 `validate:"min=2"` +} + +type ValidGenMinInt64SlicePointerStruct struct { + Field *[]int64 `valid:"min=2"` +} + +type ValidatorMinInt64SlicePointerStruct struct { + Field *[]int64 `validate:"min=2"` +} + +type ValidGenMinUintSlicePointerStruct struct { + Field *[]uint `valid:"min=2"` +} + +type ValidatorMinUintSlicePointerStruct struct { + Field *[]uint `validate:"min=2"` +} + +type ValidGenMinUint8SlicePointerStruct struct { + Field *[]uint8 `valid:"min=2"` +} + +type ValidatorMinUint8SlicePointerStruct struct { + Field *[]uint8 `validate:"min=2"` +} + +type ValidGenMinUint16SlicePointerStruct struct { + Field *[]uint16 `valid:"min=2"` +} + +type ValidatorMinUint16SlicePointerStruct struct { + Field *[]uint16 `validate:"min=2"` +} + +type ValidGenMinUint32SlicePointerStruct struct { + Field *[]uint32 `valid:"min=2"` +} + +type ValidatorMinUint32SlicePointerStruct struct { + Field *[]uint32 `validate:"min=2"` +} + +type ValidGenMinUint64SlicePointerStruct struct { + Field *[]uint64 `valid:"min=2"` +} + +type ValidatorMinUint64SlicePointerStruct struct { + Field *[]uint64 `validate:"min=2"` +} + +type ValidGenMinFloat32SlicePointerStruct struct { + Field *[]float32 `valid:"min=2"` +} + +type ValidatorMinFloat32SlicePointerStruct struct { + Field *[]float32 `validate:"min=2"` +} + +type ValidGenMinFloat64SlicePointerStruct struct { + Field *[]float64 `valid:"min=2"` +} + +type ValidatorMinFloat64SlicePointerStruct struct { + Field *[]float64 `validate:"min=2"` +} + +type ValidGenMinBoolSlicePointerStruct struct { + Field *[]bool `valid:"min=2"` +} + +type ValidatorMinBoolSlicePointerStruct struct { + Field *[]bool `validate:"min=2"` +} + +type ValidGenMinStringMapPointerStruct struct { + Field *map[string]string `valid:"min=2"` +} + +type ValidatorMinStringMapPointerStruct struct { + Field *map[string]string `validate:"min=2"` +} + +type ValidGenMinIntMapPointerStruct struct { + Field *map[int]int `valid:"min=2"` +} + +type ValidatorMinIntMapPointerStruct struct { + Field *map[int]int `validate:"min=2"` +} + +type ValidGenMinInt8MapPointerStruct struct { + Field *map[int8]int8 `valid:"min=2"` +} + +type ValidatorMinInt8MapPointerStruct struct { + Field *map[int8]int8 `validate:"min=2"` +} + +type ValidGenMinInt16MapPointerStruct struct { + Field *map[int16]int16 `valid:"min=2"` +} + +type ValidatorMinInt16MapPointerStruct struct { + Field *map[int16]int16 `validate:"min=2"` +} + +type ValidGenMinInt32MapPointerStruct struct { + Field *map[int32]int32 `valid:"min=2"` +} + +type ValidatorMinInt32MapPointerStruct struct { + Field *map[int32]int32 `validate:"min=2"` +} + +type ValidGenMinInt64MapPointerStruct struct { + Field *map[int64]int64 `valid:"min=2"` +} + +type ValidatorMinInt64MapPointerStruct struct { + Field *map[int64]int64 `validate:"min=2"` +} + +type ValidGenMinUintMapPointerStruct struct { + Field *map[uint]uint `valid:"min=2"` +} + +type ValidatorMinUintMapPointerStruct struct { + Field *map[uint]uint `validate:"min=2"` +} + +type ValidGenMinUint8MapPointerStruct struct { + Field *map[uint8]uint8 `valid:"min=2"` +} + +type ValidatorMinUint8MapPointerStruct struct { + Field *map[uint8]uint8 `validate:"min=2"` +} + +type ValidGenMinUint16MapPointerStruct struct { + Field *map[uint16]uint16 `valid:"min=2"` +} + +type ValidatorMinUint16MapPointerStruct struct { + Field *map[uint16]uint16 `validate:"min=2"` +} + +type ValidGenMinUint32MapPointerStruct struct { + Field *map[uint32]uint32 `valid:"min=2"` +} + +type ValidatorMinUint32MapPointerStruct struct { + Field *map[uint32]uint32 `validate:"min=2"` +} + +type ValidGenMinUint64MapPointerStruct struct { + Field *map[uint64]uint64 `valid:"min=2"` +} + +type ValidatorMinUint64MapPointerStruct struct { + Field *map[uint64]uint64 `validate:"min=2"` +} + +type ValidGenMinFloat32MapPointerStruct struct { + Field *map[float32]float32 `valid:"min=2"` +} + +type ValidatorMinFloat32MapPointerStruct struct { + Field *map[float32]float32 `validate:"min=2"` +} + +type ValidGenMinFloat64MapPointerStruct struct { + Field *map[float64]float64 `valid:"min=2"` +} + +type ValidatorMinFloat64MapPointerStruct struct { + Field *map[float64]float64 `validate:"min=2"` +} + +type ValidGenMinBoolMapPointerStruct struct { + Field *map[bool]bool `valid:"min=2"` +} + +type ValidatorMinBoolMapPointerStruct struct { + Field *map[bool]bool `validate:"min=2"` +} + +type ValidGenMaxStringPointerStruct struct { + Field *string `valid:"max=3"` +} + +type ValidatorMaxStringPointerStruct struct { + Field *string `validate:"max=3"` +} + +type ValidGenMaxStringSlicePointerStruct struct { + Field *[]string `valid:"max=2"` +} + +type ValidatorMaxStringSlicePointerStruct struct { + Field *[]string `validate:"max=2"` +} + +type ValidGenMaxIntSlicePointerStruct struct { + Field *[]int `valid:"max=2"` +} + +type ValidatorMaxIntSlicePointerStruct struct { + Field *[]int `validate:"max=2"` +} + +type ValidGenMaxInt8SlicePointerStruct struct { + Field *[]int8 `valid:"max=2"` +} + +type ValidatorMaxInt8SlicePointerStruct struct { + Field *[]int8 `validate:"max=2"` +} + +type ValidGenMaxInt16SlicePointerStruct struct { + Field *[]int16 `valid:"max=2"` +} + +type ValidatorMaxInt16SlicePointerStruct struct { + Field *[]int16 `validate:"max=2"` +} + +type ValidGenMaxInt32SlicePointerStruct struct { + Field *[]int32 `valid:"max=2"` +} + +type ValidatorMaxInt32SlicePointerStruct struct { + Field *[]int32 `validate:"max=2"` +} + +type ValidGenMaxInt64SlicePointerStruct struct { + Field *[]int64 `valid:"max=2"` +} + +type ValidatorMaxInt64SlicePointerStruct struct { + Field *[]int64 `validate:"max=2"` +} + +type ValidGenMaxUintSlicePointerStruct struct { + Field *[]uint `valid:"max=2"` +} + +type ValidatorMaxUintSlicePointerStruct struct { + Field *[]uint `validate:"max=2"` +} + +type ValidGenMaxUint8SlicePointerStruct struct { + Field *[]uint8 `valid:"max=2"` +} + +type ValidatorMaxUint8SlicePointerStruct struct { + Field *[]uint8 `validate:"max=2"` +} + +type ValidGenMaxUint16SlicePointerStruct struct { + Field *[]uint16 `valid:"max=2"` +} + +type ValidatorMaxUint16SlicePointerStruct struct { + Field *[]uint16 `validate:"max=2"` +} + +type ValidGenMaxUint32SlicePointerStruct struct { + Field *[]uint32 `valid:"max=2"` +} + +type ValidatorMaxUint32SlicePointerStruct struct { + Field *[]uint32 `validate:"max=2"` +} + +type ValidGenMaxUint64SlicePointerStruct struct { + Field *[]uint64 `valid:"max=2"` +} + +type ValidatorMaxUint64SlicePointerStruct struct { + Field *[]uint64 `validate:"max=2"` +} + +type ValidGenMaxFloat32SlicePointerStruct struct { + Field *[]float32 `valid:"max=2"` +} + +type ValidatorMaxFloat32SlicePointerStruct struct { + Field *[]float32 `validate:"max=2"` +} + +type ValidGenMaxFloat64SlicePointerStruct struct { + Field *[]float64 `valid:"max=2"` +} + +type ValidatorMaxFloat64SlicePointerStruct struct { + Field *[]float64 `validate:"max=2"` +} + +type ValidGenMaxBoolSlicePointerStruct struct { + Field *[]bool `valid:"max=2"` +} + +type ValidatorMaxBoolSlicePointerStruct struct { + Field *[]bool `validate:"max=2"` +} + +type ValidGenMaxStringMapPointerStruct struct { + Field *map[string]string `valid:"max=2"` +} + +type ValidatorMaxStringMapPointerStruct struct { + Field *map[string]string `validate:"max=2"` +} + +type ValidGenMaxIntMapPointerStruct struct { + Field *map[int]int `valid:"max=2"` +} + +type ValidatorMaxIntMapPointerStruct struct { + Field *map[int]int `validate:"max=2"` +} + +type ValidGenMaxInt8MapPointerStruct struct { + Field *map[int8]int8 `valid:"max=2"` +} + +type ValidatorMaxInt8MapPointerStruct struct { + Field *map[int8]int8 `validate:"max=2"` +} + +type ValidGenMaxInt16MapPointerStruct struct { + Field *map[int16]int16 `valid:"max=2"` +} + +type ValidatorMaxInt16MapPointerStruct struct { + Field *map[int16]int16 `validate:"max=2"` +} + +type ValidGenMaxInt32MapPointerStruct struct { + Field *map[int32]int32 `valid:"max=2"` +} + +type ValidatorMaxInt32MapPointerStruct struct { + Field *map[int32]int32 `validate:"max=2"` +} + +type ValidGenMaxInt64MapPointerStruct struct { + Field *map[int64]int64 `valid:"max=2"` +} + +type ValidatorMaxInt64MapPointerStruct struct { + Field *map[int64]int64 `validate:"max=2"` +} + +type ValidGenMaxUintMapPointerStruct struct { + Field *map[uint]uint `valid:"max=2"` +} + +type ValidatorMaxUintMapPointerStruct struct { + Field *map[uint]uint `validate:"max=2"` +} + +type ValidGenMaxUint8MapPointerStruct struct { + Field *map[uint8]uint8 `valid:"max=2"` +} + +type ValidatorMaxUint8MapPointerStruct struct { + Field *map[uint8]uint8 `validate:"max=2"` +} + +type ValidGenMaxUint16MapPointerStruct struct { + Field *map[uint16]uint16 `valid:"max=2"` +} + +type ValidatorMaxUint16MapPointerStruct struct { + Field *map[uint16]uint16 `validate:"max=2"` +} + +type ValidGenMaxUint32MapPointerStruct struct { + Field *map[uint32]uint32 `valid:"max=2"` +} + +type ValidatorMaxUint32MapPointerStruct struct { + Field *map[uint32]uint32 `validate:"max=2"` +} + +type ValidGenMaxUint64MapPointerStruct struct { + Field *map[uint64]uint64 `valid:"max=2"` +} + +type ValidatorMaxUint64MapPointerStruct struct { + Field *map[uint64]uint64 `validate:"max=2"` +} + +type ValidGenMaxFloat32MapPointerStruct struct { + Field *map[float32]float32 `valid:"max=2"` +} + +type ValidatorMaxFloat32MapPointerStruct struct { + Field *map[float32]float32 `validate:"max=2"` +} + +type ValidGenMaxFloat64MapPointerStruct struct { + Field *map[float64]float64 `valid:"max=2"` +} + +type ValidatorMaxFloat64MapPointerStruct struct { + Field *map[float64]float64 `validate:"max=2"` +} + +type ValidGenMaxBoolMapPointerStruct struct { + Field *map[bool]bool `valid:"max=1"` +} + +type ValidatorMaxBoolMapPointerStruct struct { + Field *map[bool]bool `validate:"max=1"` +} + +type ValidGenEq_ignore_caseStringPointerStruct struct { + Field *string `valid:"eq_ignore_case=abcde"` +} + +type ValidatorEq_ignore_caseStringPointerStruct struct { + Field *string `validate:"eq_ignore_case=abcde"` +} + +type ValidGenNeq_ignore_caseStringPointerStruct struct { + Field *string `valid:"neq_ignore_case=abcde"` +} + +type ValidatorNeq_ignore_caseStringPointerStruct struct { + Field *string `validate:"ne_ignore_case=abcde"` +} + +type ValidGenLenStringPointerStruct struct { + Field *string `valid:"len=2"` +} + +type ValidatorLenStringPointerStruct struct { + Field *string `validate:"len=2"` +} + +type ValidGenLenStringSlicePointerStruct struct { + Field *[]string `valid:"len=2"` +} + +type ValidatorLenStringSlicePointerStruct struct { + Field *[]string `validate:"len=2"` +} + +type ValidGenLenIntSlicePointerStruct struct { + Field *[]int `valid:"len=2"` +} + +type ValidatorLenIntSlicePointerStruct struct { + Field *[]int `validate:"len=2"` +} + +type ValidGenLenInt8SlicePointerStruct struct { + Field *[]int8 `valid:"len=2"` +} + +type ValidatorLenInt8SlicePointerStruct struct { + Field *[]int8 `validate:"len=2"` +} + +type ValidGenLenInt16SlicePointerStruct struct { + Field *[]int16 `valid:"len=2"` +} + +type ValidatorLenInt16SlicePointerStruct struct { + Field *[]int16 `validate:"len=2"` +} + +type ValidGenLenInt32SlicePointerStruct struct { + Field *[]int32 `valid:"len=2"` +} + +type ValidatorLenInt32SlicePointerStruct struct { + Field *[]int32 `validate:"len=2"` +} + +type ValidGenLenInt64SlicePointerStruct struct { + Field *[]int64 `valid:"len=2"` +} + +type ValidatorLenInt64SlicePointerStruct struct { + Field *[]int64 `validate:"len=2"` +} + +type ValidGenLenUintSlicePointerStruct struct { + Field *[]uint `valid:"len=2"` +} + +type ValidatorLenUintSlicePointerStruct struct { + Field *[]uint `validate:"len=2"` +} + +type ValidGenLenUint8SlicePointerStruct struct { + Field *[]uint8 `valid:"len=2"` +} + +type ValidatorLenUint8SlicePointerStruct struct { + Field *[]uint8 `validate:"len=2"` +} + +type ValidGenLenUint16SlicePointerStruct struct { + Field *[]uint16 `valid:"len=2"` +} + +type ValidatorLenUint16SlicePointerStruct struct { + Field *[]uint16 `validate:"len=2"` +} + +type ValidGenLenUint32SlicePointerStruct struct { + Field *[]uint32 `valid:"len=2"` +} + +type ValidatorLenUint32SlicePointerStruct struct { + Field *[]uint32 `validate:"len=2"` +} + +type ValidGenLenUint64SlicePointerStruct struct { + Field *[]uint64 `valid:"len=2"` +} + +type ValidatorLenUint64SlicePointerStruct struct { + Field *[]uint64 `validate:"len=2"` +} + +type ValidGenLenFloat32SlicePointerStruct struct { + Field *[]float32 `valid:"len=2"` +} + +type ValidatorLenFloat32SlicePointerStruct struct { + Field *[]float32 `validate:"len=2"` +} + +type ValidGenLenFloat64SlicePointerStruct struct { + Field *[]float64 `valid:"len=2"` +} + +type ValidatorLenFloat64SlicePointerStruct struct { + Field *[]float64 `validate:"len=2"` +} + +type ValidGenLenBoolSlicePointerStruct struct { + Field *[]bool `valid:"len=2"` +} + +type ValidatorLenBoolSlicePointerStruct struct { + Field *[]bool `validate:"len=2"` +} + +type ValidGenLenStringMapPointerStruct struct { + Field *map[string]string `valid:"len=2"` +} + +type ValidatorLenStringMapPointerStruct struct { + Field *map[string]string `validate:"len=2"` +} + +type ValidGenLenIntMapPointerStruct struct { + Field *map[int]int `valid:"len=2"` +} + +type ValidatorLenIntMapPointerStruct struct { + Field *map[int]int `validate:"len=2"` +} + +type ValidGenLenInt8MapPointerStruct struct { + Field *map[int8]int8 `valid:"len=2"` +} + +type ValidatorLenInt8MapPointerStruct struct { + Field *map[int8]int8 `validate:"len=2"` +} + +type ValidGenLenInt16MapPointerStruct struct { + Field *map[int16]int16 `valid:"len=2"` +} + +type ValidatorLenInt16MapPointerStruct struct { + Field *map[int16]int16 `validate:"len=2"` +} + +type ValidGenLenInt32MapPointerStruct struct { + Field *map[int32]int32 `valid:"len=2"` +} + +type ValidatorLenInt32MapPointerStruct struct { + Field *map[int32]int32 `validate:"len=2"` +} + +type ValidGenLenInt64MapPointerStruct struct { + Field *map[int64]int64 `valid:"len=2"` +} + +type ValidatorLenInt64MapPointerStruct struct { + Field *map[int64]int64 `validate:"len=2"` +} + +type ValidGenLenUintMapPointerStruct struct { + Field *map[uint]uint `valid:"len=2"` +} + +type ValidatorLenUintMapPointerStruct struct { + Field *map[uint]uint `validate:"len=2"` +} + +type ValidGenLenUint8MapPointerStruct struct { + Field *map[uint8]uint8 `valid:"len=2"` +} + +type ValidatorLenUint8MapPointerStruct struct { + Field *map[uint8]uint8 `validate:"len=2"` +} + +type ValidGenLenUint16MapPointerStruct struct { + Field *map[uint16]uint16 `valid:"len=2"` +} + +type ValidatorLenUint16MapPointerStruct struct { + Field *map[uint16]uint16 `validate:"len=2"` +} + +type ValidGenLenUint32MapPointerStruct struct { + Field *map[uint32]uint32 `valid:"len=2"` +} + +type ValidatorLenUint32MapPointerStruct struct { + Field *map[uint32]uint32 `validate:"len=2"` +} + +type ValidGenLenUint64MapPointerStruct struct { + Field *map[uint64]uint64 `valid:"len=2"` +} + +type ValidatorLenUint64MapPointerStruct struct { + Field *map[uint64]uint64 `validate:"len=2"` +} + +type ValidGenLenFloat32MapPointerStruct struct { + Field *map[float32]float32 `valid:"len=2"` +} + +type ValidatorLenFloat32MapPointerStruct struct { + Field *map[float32]float32 `validate:"len=2"` +} + +type ValidGenLenFloat64MapPointerStruct struct { + Field *map[float64]float64 `valid:"len=2"` +} + +type ValidatorLenFloat64MapPointerStruct struct { + Field *map[float64]float64 `validate:"len=2"` +} + +type ValidGenLenBoolMapPointerStruct struct { + Field *map[bool]bool `valid:"len=2"` +} + +type ValidatorLenBoolMapPointerStruct struct { + Field *map[bool]bool `validate:"len=2"` +} + +type ValidGenInStringPointerStruct struct { + Field *string `valid:"in=ab cd ef"` +} + +type ValidatorInStringPointerStruct struct { + Field *string `validate:"oneof=ab cd ef"` +} + +type ValidGenInIntPointerStruct struct { + Field *int `valid:"in=12 34 56"` +} + +type ValidatorInIntPointerStruct struct { + Field *int `validate:"oneof=12 34 56"` +} + +type ValidGenInInt8PointerStruct struct { + Field *int8 `valid:"in=12 34 56"` +} + +type ValidatorInInt8PointerStruct struct { + Field *int8 `validate:"oneof=12 34 56"` +} + +type ValidGenInInt16PointerStruct struct { + Field *int16 `valid:"in=12 34 56"` +} + +type ValidatorInInt16PointerStruct struct { + Field *int16 `validate:"oneof=12 34 56"` +} + +type ValidGenInInt32PointerStruct struct { + Field *int32 `valid:"in=12 34 56"` +} + +type ValidatorInInt32PointerStruct struct { + Field *int32 `validate:"oneof=12 34 56"` +} + +type ValidGenInInt64PointerStruct struct { + Field *int64 `valid:"in=12 34 56"` +} + +type ValidatorInInt64PointerStruct struct { + Field *int64 `validate:"oneof=12 34 56"` +} + +type ValidGenInUintPointerStruct struct { + Field *uint `valid:"in=12 34 56"` +} + +type ValidatorInUintPointerStruct struct { + Field *uint `validate:"oneof=12 34 56"` +} + +type ValidGenInUint8PointerStruct struct { + Field *uint8 `valid:"in=12 34 56"` +} + +type ValidatorInUint8PointerStruct struct { + Field *uint8 `validate:"oneof=12 34 56"` +} + +type ValidGenInUint16PointerStruct struct { + Field *uint16 `valid:"in=12 34 56"` +} + +type ValidatorInUint16PointerStruct struct { + Field *uint16 `validate:"oneof=12 34 56"` +} + +type ValidGenInUint32PointerStruct struct { + Field *uint32 `valid:"in=12 34 56"` +} + +type ValidatorInUint32PointerStruct struct { + Field *uint32 `validate:"oneof=12 34 56"` +} + +type ValidGenInUint64PointerStruct struct { + Field *uint64 `valid:"in=12 34 56"` +} + +type ValidatorInUint64PointerStruct struct { + Field *uint64 `validate:"oneof=12 34 56"` +} + +func BenchmarkValidGenEmailStringPointer(b *testing.B) { + var validInput string = "abcde@example.com" + data := &ValidGenEmailStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEmailStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEmailStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "abcde@example.com" + + data := &ValidatorEmailStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredStringPointer(b *testing.B) { + var validInput string = "abcde" + data := &ValidGenRequiredStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "abcde" + + data := &ValidatorRequiredStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredIntPointer(b *testing.B) { + var validInput int = 32 + data := &ValidGenRequiredIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredIntPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredIntPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int = 32 + + data := &ValidatorRequiredIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt8Pointer(b *testing.B) { + var validInput int8 = 32 + data := &ValidGenRequiredInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int8 = 32 + + data := &ValidatorRequiredInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt16Pointer(b *testing.B) { + var validInput int16 = 32 + data := &ValidGenRequiredInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int16 = 32 + + data := &ValidatorRequiredInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt32Pointer(b *testing.B) { + var validInput int32 = 32 + data := &ValidGenRequiredInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int32 = 32 + + data := &ValidatorRequiredInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt64Pointer(b *testing.B) { + var validInput int64 = 32 + data := &ValidGenRequiredInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int64 = 32 + + data := &ValidatorRequiredInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUintPointer(b *testing.B) { + var validInput uint = 32 + data := &ValidGenRequiredUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUintPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUintPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint = 32 + + data := &ValidatorRequiredUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint8Pointer(b *testing.B) { + var validInput uint8 = 32 + data := &ValidGenRequiredUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint8 = 32 + + data := &ValidatorRequiredUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint16Pointer(b *testing.B) { + var validInput uint16 = 32 + data := &ValidGenRequiredUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint16 = 32 + + data := &ValidatorRequiredUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint32Pointer(b *testing.B) { + var validInput uint32 = 32 + data := &ValidGenRequiredUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint32 = 32 + + data := &ValidatorRequiredUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint64Pointer(b *testing.B) { + var validInput uint64 = 32 + data := &ValidGenRequiredUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint64 = 32 + + data := &ValidatorRequiredUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat32Pointer(b *testing.B) { + var validInput float32 = 12.34 + data := &ValidGenRequiredFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredFloat32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float32 = 12.34 + + data := &ValidatorRequiredFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat64Pointer(b *testing.B) { + var validInput float64 = 12.34 + data := &ValidGenRequiredFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredFloat64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float64 = 12.34 + + data := &ValidatorRequiredFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredBoolPointer(b *testing.B) { + var validInput bool = true + data := &ValidGenRequiredBoolPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredBoolPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredBoolPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput bool = true + + data := &ValidatorRequiredBoolPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredStringSlicePointer(b *testing.B) { + var validInput []string = []string{"abcde"} + data := &ValidGenRequiredStringSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredStringSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredStringSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []string = []string{"abcde"} + + data := &ValidatorRequiredStringSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredIntSlicePointer(b *testing.B) { + var validInput []int = []int{32} + data := &ValidGenRequiredIntSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredIntSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredIntSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int = []int{32} + + data := &ValidatorRequiredIntSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt8SlicePointer(b *testing.B) { + var validInput []int8 = []int8{32} + data := &ValidGenRequiredInt8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt8SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt8SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int8 = []int8{32} + + data := &ValidatorRequiredInt8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt16SlicePointer(b *testing.B) { + var validInput []int16 = []int16{32} + data := &ValidGenRequiredInt16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt16SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt16SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int16 = []int16{32} + + data := &ValidatorRequiredInt16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt32SlicePointer(b *testing.B) { + var validInput []int32 = []int32{32} + data := &ValidGenRequiredInt32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int32 = []int32{32} + + data := &ValidatorRequiredInt32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt64SlicePointer(b *testing.B) { + var validInput []int64 = []int64{32} + data := &ValidGenRequiredInt64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int64 = []int64{32} + + data := &ValidatorRequiredInt64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUintSlicePointer(b *testing.B) { + var validInput []uint = []uint{32} + data := &ValidGenRequiredUintSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUintSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUintSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint = []uint{32} + + data := &ValidatorRequiredUintSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint8SlicePointer(b *testing.B) { + var validInput []uint8 = []uint8{32} + data := &ValidGenRequiredUint8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint8SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint8SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint8 = []uint8{32} + + data := &ValidatorRequiredUint8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint16SlicePointer(b *testing.B) { + var validInput []uint16 = []uint16{32} + data := &ValidGenRequiredUint16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint16SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint16SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint16 = []uint16{32} + + data := &ValidatorRequiredUint16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint32SlicePointer(b *testing.B) { + var validInput []uint32 = []uint32{32} + data := &ValidGenRequiredUint32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint32 = []uint32{32} + + data := &ValidatorRequiredUint32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint64SlicePointer(b *testing.B) { + var validInput []uint64 = []uint64{32} + data := &ValidGenRequiredUint64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint64 = []uint64{32} + + data := &ValidatorRequiredUint64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat32SlicePointer(b *testing.B) { + var validInput []float32 = []float32{12.34} + data := &ValidGenRequiredFloat32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredFloat32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []float32 = []float32{12.34} + + data := &ValidatorRequiredFloat32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat64SlicePointer(b *testing.B) { + var validInput []float64 = []float64{12.34} + data := &ValidGenRequiredFloat64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredFloat64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []float64 = []float64{12.34} + + data := &ValidatorRequiredFloat64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredBoolSlicePointer(b *testing.B) { + var validInput []bool = []bool{true} + data := &ValidGenRequiredBoolSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredBoolSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredBoolSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []bool = []bool{true} + + data := &ValidatorRequiredBoolSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredStringArrayPointer(b *testing.B) { + var validInput [3]string = [3]string{"abcde"} + data := &ValidGenRequiredStringArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredStringArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredStringArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]string = [3]string{"abcde"} + + data := &ValidatorRequiredStringArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredIntArrayPointer(b *testing.B) { + var validInput [3]int = [3]int{32} + data := &ValidGenRequiredIntArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredIntArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredIntArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]int = [3]int{32} + + data := &ValidatorRequiredIntArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt8ArrayPointer(b *testing.B) { + var validInput [3]int8 = [3]int8{32} + data := &ValidGenRequiredInt8ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt8ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt8ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]int8 = [3]int8{32} + + data := &ValidatorRequiredInt8ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt16ArrayPointer(b *testing.B) { + var validInput [3]int16 = [3]int16{32} + data := &ValidGenRequiredInt16ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt16ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt16ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]int16 = [3]int16{32} + + data := &ValidatorRequiredInt16ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt32ArrayPointer(b *testing.B) { + var validInput [3]int32 = [3]int32{32} + data := &ValidGenRequiredInt32ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt32ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt32ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]int32 = [3]int32{32} + + data := &ValidatorRequiredInt32ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt64ArrayPointer(b *testing.B) { + var validInput [3]int64 = [3]int64{32} + data := &ValidGenRequiredInt64ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt64ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt64ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]int64 = [3]int64{32} + + data := &ValidatorRequiredInt64ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUintArrayPointer(b *testing.B) { + var validInput [3]uint = [3]uint{32} + data := &ValidGenRequiredUintArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUintArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUintArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]uint = [3]uint{32} + + data := &ValidatorRequiredUintArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint8ArrayPointer(b *testing.B) { + var validInput [3]uint8 = [3]uint8{32} + data := &ValidGenRequiredUint8ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint8ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint8ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]uint8 = [3]uint8{32} + + data := &ValidatorRequiredUint8ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint16ArrayPointer(b *testing.B) { + var validInput [3]uint16 = [3]uint16{32} + data := &ValidGenRequiredUint16ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint16ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint16ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]uint16 = [3]uint16{32} + + data := &ValidatorRequiredUint16ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint32ArrayPointer(b *testing.B) { + var validInput [3]uint32 = [3]uint32{32} + data := &ValidGenRequiredUint32ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint32ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint32ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]uint32 = [3]uint32{32} + + data := &ValidatorRequiredUint32ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint64ArrayPointer(b *testing.B) { + var validInput [3]uint64 = [3]uint64{32} + data := &ValidGenRequiredUint64ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint64ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint64ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]uint64 = [3]uint64{32} + + data := &ValidatorRequiredUint64ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat32ArrayPointer(b *testing.B) { + var validInput [3]float32 = [3]float32{12.34} + data := &ValidGenRequiredFloat32ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredFloat32ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat32ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]float32 = [3]float32{12.34} + + data := &ValidatorRequiredFloat32ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat64ArrayPointer(b *testing.B) { + var validInput [3]float64 = [3]float64{12.34} + data := &ValidGenRequiredFloat64ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredFloat64ArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat64ArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]float64 = [3]float64{12.34} + + data := &ValidatorRequiredFloat64ArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredBoolArrayPointer(b *testing.B) { + var validInput [3]bool = [3]bool{true} + data := &ValidGenRequiredBoolArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredBoolArrayPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredBoolArrayPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput [3]bool = [3]bool{true} + + data := &ValidatorRequiredBoolArrayPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredStringMapPointer(b *testing.B) { + var validInput map[string]string = map[string]string{"abcde": "value"} + data := &ValidGenRequiredStringMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredStringMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredStringMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[string]string = map[string]string{"abcde": "value"} + + data := &ValidatorRequiredStringMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredIntMapPointer(b *testing.B) { + var validInput map[int]int = map[int]int{32: 64} + data := &ValidGenRequiredIntMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredIntMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredIntMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int]int = map[int]int{32: 64} + + data := &ValidatorRequiredIntMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt8MapPointer(b *testing.B) { + var validInput map[int8]int8 = map[int8]int8{32: 64} + data := &ValidGenRequiredInt8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt8MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt8MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int8]int8 = map[int8]int8{32: 64} + + data := &ValidatorRequiredInt8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt16MapPointer(b *testing.B) { + var validInput map[int16]int16 = map[int16]int16{32: 64} + data := &ValidGenRequiredInt16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt16MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt16MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int16]int16 = map[int16]int16{32: 64} + + data := &ValidatorRequiredInt16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt32MapPointer(b *testing.B) { + var validInput map[int32]int32 = map[int32]int32{32: 64} + data := &ValidGenRequiredInt32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int32]int32 = map[int32]int32{32: 64} + + data := &ValidatorRequiredInt32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredInt64MapPointer(b *testing.B) { + var validInput map[int64]int64 = map[int64]int64{32: 64} + data := &ValidGenRequiredInt64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredInt64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredInt64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int64]int64 = map[int64]int64{32: 64} + + data := &ValidatorRequiredInt64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUintMapPointer(b *testing.B) { + var validInput map[uint]uint = map[uint]uint{32: 64} + data := &ValidGenRequiredUintMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUintMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUintMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint]uint = map[uint]uint{32: 64} + + data := &ValidatorRequiredUintMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint8MapPointer(b *testing.B) { + var validInput map[uint8]uint8 = map[uint8]uint8{32: 64} + data := &ValidGenRequiredUint8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint8MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint8MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint8]uint8 = map[uint8]uint8{32: 64} + + data := &ValidatorRequiredUint8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint16MapPointer(b *testing.B) { + var validInput map[uint16]uint16 = map[uint16]uint16{32: 64} + data := &ValidGenRequiredUint16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint16MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint16MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint16]uint16 = map[uint16]uint16{32: 64} + + data := &ValidatorRequiredUint16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint32MapPointer(b *testing.B) { + var validInput map[uint32]uint32 = map[uint32]uint32{32: 64} + data := &ValidGenRequiredUint32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint32]uint32 = map[uint32]uint32{32: 64} + + data := &ValidatorRequiredUint32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredUint64MapPointer(b *testing.B) { + var validInput map[uint64]uint64 = map[uint64]uint64{32: 64} + data := &ValidGenRequiredUint64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredUint64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredUint64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint64]uint64 = map[uint64]uint64{32: 64} + + data := &ValidatorRequiredUint64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat32MapPointer(b *testing.B) { + var validInput map[float32]float32 = map[float32]float32{12.34: 56.78} + data := &ValidGenRequiredFloat32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredFloat32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[float32]float32 = map[float32]float32{12.34: 56.78} + + data := &ValidatorRequiredFloat32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredFloat64MapPointer(b *testing.B) { + var validInput map[float64]float64 = map[float64]float64{12.34: 56.78} + data := &ValidGenRequiredFloat64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredFloat64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredFloat64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[float64]float64 = map[float64]float64{12.34: 56.78} + + data := &ValidatorRequiredFloat64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenRequiredBoolMapPointer(b *testing.B) { + var validInput map[bool]bool = map[bool]bool{true: true} + data := &ValidGenRequiredBoolMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenRequiredBoolMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorRequiredBoolMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[bool]bool = map[bool]bool{true: true} + + data := &ValidatorRequiredBoolMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqStringPointer(b *testing.B) { + var validInput string = "abcde" + data := &ValidGenEqStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "abcde" + + data := &ValidatorEqStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqIntPointer(b *testing.B) { + var validInput int = 32 + data := &ValidGenEqIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqIntPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqIntPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int = 32 + + data := &ValidatorEqIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqInt8Pointer(b *testing.B) { + var validInput int8 = 32 + data := &ValidGenEqInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqInt8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqInt8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int8 = 32 + + data := &ValidatorEqInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqInt16Pointer(b *testing.B) { + var validInput int16 = 32 + data := &ValidGenEqInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqInt16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqInt16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int16 = 32 + + data := &ValidatorEqInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqInt32Pointer(b *testing.B) { + var validInput int32 = 32 + data := &ValidGenEqInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqInt32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqInt32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int32 = 32 + + data := &ValidatorEqInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqInt64Pointer(b *testing.B) { + var validInput int64 = 32 + data := &ValidGenEqInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqInt64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqInt64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int64 = 32 + + data := &ValidatorEqInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUintPointer(b *testing.B) { + var validInput uint = 32 + data := &ValidGenEqUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqUintPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUintPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint = 32 + + data := &ValidatorEqUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUint8Pointer(b *testing.B) { + var validInput uint8 = 32 + data := &ValidGenEqUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqUint8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUint8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint8 = 32 + + data := &ValidatorEqUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUint16Pointer(b *testing.B) { + var validInput uint16 = 32 + data := &ValidGenEqUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqUint16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUint16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint16 = 32 + + data := &ValidatorEqUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUint32Pointer(b *testing.B) { + var validInput uint32 = 32 + data := &ValidGenEqUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqUint32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUint32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint32 = 32 + + data := &ValidatorEqUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqUint64Pointer(b *testing.B) { + var validInput uint64 = 32 + data := &ValidGenEqUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqUint64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqUint64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint64 = 32 + + data := &ValidatorEqUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqFloat32Pointer(b *testing.B) { + var validInput float32 = 12.34 + data := &ValidGenEqFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqFloat32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqFloat32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float32 = 12.34 + + data := &ValidatorEqFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqFloat64Pointer(b *testing.B) { + var validInput float64 = 12.34 + data := &ValidGenEqFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqFloat64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqFloat64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float64 = 12.34 + + data := &ValidatorEqFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEqBoolPointer(b *testing.B) { + var validInput bool = true + data := &ValidGenEqBoolPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEqBoolPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEqBoolPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput bool = true + + data := &ValidatorEqBoolPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqStringPointer(b *testing.B) { + var validInput string = "fghij" + data := &ValidGenNeqStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "fghij" + + data := &ValidatorNeqStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqIntPointer(b *testing.B) { + var validInput int = 64 + data := &ValidGenNeqIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqIntPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqIntPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int = 64 + + data := &ValidatorNeqIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqInt8Pointer(b *testing.B) { + var validInput int8 = 64 + data := &ValidGenNeqInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqInt8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqInt8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int8 = 64 + + data := &ValidatorNeqInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqInt16Pointer(b *testing.B) { + var validInput int16 = 64 + data := &ValidGenNeqInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqInt16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqInt16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int16 = 64 + + data := &ValidatorNeqInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqInt32Pointer(b *testing.B) { + var validInput int32 = 64 + data := &ValidGenNeqInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqInt32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqInt32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int32 = 64 + + data := &ValidatorNeqInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqInt64Pointer(b *testing.B) { + var validInput int64 = 64 + data := &ValidGenNeqInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqInt64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqInt64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int64 = 64 + + data := &ValidatorNeqInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUintPointer(b *testing.B) { + var validInput uint = 64 + data := &ValidGenNeqUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqUintPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUintPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint = 64 + + data := &ValidatorNeqUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUint8Pointer(b *testing.B) { + var validInput uint8 = 64 + data := &ValidGenNeqUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqUint8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUint8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint8 = 64 + + data := &ValidatorNeqUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUint16Pointer(b *testing.B) { + var validInput uint16 = 64 + data := &ValidGenNeqUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqUint16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUint16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint16 = 64 + + data := &ValidatorNeqUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUint32Pointer(b *testing.B) { + var validInput uint32 = 64 + data := &ValidGenNeqUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqUint32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUint32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint32 = 64 + + data := &ValidatorNeqUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqUint64Pointer(b *testing.B) { + var validInput uint64 = 64 + data := &ValidGenNeqUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqUint64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqUint64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint64 = 64 + + data := &ValidatorNeqUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqFloat32Pointer(b *testing.B) { + var validInput float32 = 34.56 + data := &ValidGenNeqFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqFloat32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqFloat32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float32 = 34.56 + + data := &ValidatorNeqFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqFloat64Pointer(b *testing.B) { + var validInput float64 = 34.56 + data := &ValidGenNeqFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqFloat64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqFloat64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float64 = 34.56 + + data := &ValidatorNeqFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeqBoolPointer(b *testing.B) { + var validInput bool = false + data := &ValidGenNeqBoolPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeqBoolPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeqBoolPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput bool = false + + data := &ValidatorNeqBoolPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtIntPointer(b *testing.B) { + var validInput int = 33 + data := &ValidGenGtIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtIntPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtIntPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int = 33 + + data := &ValidatorGtIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtInt8Pointer(b *testing.B) { + var validInput int8 = 33 + data := &ValidGenGtInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtInt8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtInt8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int8 = 33 + + data := &ValidatorGtInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtInt16Pointer(b *testing.B) { + var validInput int16 = 33 + data := &ValidGenGtInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtInt16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtInt16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int16 = 33 + + data := &ValidatorGtInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtInt32Pointer(b *testing.B) { + var validInput int32 = 33 + data := &ValidGenGtInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtInt32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtInt32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int32 = 33 + + data := &ValidatorGtInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtInt64Pointer(b *testing.B) { + var validInput int64 = 33 + data := &ValidGenGtInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtInt64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtInt64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int64 = 33 + + data := &ValidatorGtInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUintPointer(b *testing.B) { + var validInput uint = 33 + data := &ValidGenGtUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtUintPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUintPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint = 33 + + data := &ValidatorGtUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUint8Pointer(b *testing.B) { + var validInput uint8 = 33 + data := &ValidGenGtUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtUint8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUint8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint8 = 33 + + data := &ValidatorGtUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUint16Pointer(b *testing.B) { + var validInput uint16 = 33 + data := &ValidGenGtUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtUint16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUint16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint16 = 33 + + data := &ValidatorGtUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUint32Pointer(b *testing.B) { + var validInput uint32 = 33 + data := &ValidGenGtUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtUint32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUint32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint32 = 33 + + data := &ValidatorGtUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtUint64Pointer(b *testing.B) { + var validInput uint64 = 33 + data := &ValidGenGtUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtUint64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtUint64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint64 = 33 + + data := &ValidatorGtUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtFloat32Pointer(b *testing.B) { + var validInput float32 = 12.35 + data := &ValidGenGtFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtFloat32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtFloat32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float32 = 12.35 + + data := &ValidatorGtFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGtFloat64Pointer(b *testing.B) { + var validInput float64 = 12.35 + data := &ValidGenGtFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGtFloat64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGtFloat64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float64 = 12.35 + + data := &ValidatorGtFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteIntPointer(b *testing.B) { + var validInput int = 32 + data := &ValidGenGteIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteIntPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteIntPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int = 32 + + data := &ValidatorGteIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteInt8Pointer(b *testing.B) { + var validInput int8 = 32 + data := &ValidGenGteInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteInt8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteInt8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int8 = 32 + + data := &ValidatorGteInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteInt16Pointer(b *testing.B) { + var validInput int16 = 32 + data := &ValidGenGteInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteInt16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteInt16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int16 = 32 + + data := &ValidatorGteInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteInt32Pointer(b *testing.B) { + var validInput int32 = 32 + data := &ValidGenGteInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteInt32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteInt32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int32 = 32 + + data := &ValidatorGteInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteInt64Pointer(b *testing.B) { + var validInput int64 = 32 + data := &ValidGenGteInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteInt64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteInt64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int64 = 32 + + data := &ValidatorGteInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUintPointer(b *testing.B) { + var validInput uint = 32 + data := &ValidGenGteUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteUintPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUintPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint = 32 + + data := &ValidatorGteUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUint8Pointer(b *testing.B) { + var validInput uint8 = 32 + data := &ValidGenGteUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteUint8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUint8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint8 = 32 + + data := &ValidatorGteUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUint16Pointer(b *testing.B) { + var validInput uint16 = 32 + data := &ValidGenGteUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteUint16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUint16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint16 = 32 + + data := &ValidatorGteUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUint32Pointer(b *testing.B) { + var validInput uint32 = 32 + data := &ValidGenGteUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteUint32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUint32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint32 = 32 + + data := &ValidatorGteUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteUint64Pointer(b *testing.B) { + var validInput uint64 = 32 + data := &ValidGenGteUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteUint64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteUint64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint64 = 32 + + data := &ValidatorGteUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteFloat32Pointer(b *testing.B) { + var validInput float32 = 12.34 + data := &ValidGenGteFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteFloat32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteFloat32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float32 = 12.34 + + data := &ValidatorGteFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenGteFloat64Pointer(b *testing.B) { + var validInput float64 = 12.34 + data := &ValidGenGteFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenGteFloat64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorGteFloat64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float64 = 12.34 + + data := &ValidatorGteFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtIntPointer(b *testing.B) { + var validInput int = 31 + data := &ValidGenLtIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtIntPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtIntPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int = 31 + + data := &ValidatorLtIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtInt8Pointer(b *testing.B) { + var validInput int8 = 31 + data := &ValidGenLtInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtInt8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtInt8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int8 = 31 + + data := &ValidatorLtInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtInt16Pointer(b *testing.B) { + var validInput int16 = 31 + data := &ValidGenLtInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtInt16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtInt16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int16 = 31 + + data := &ValidatorLtInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtInt32Pointer(b *testing.B) { + var validInput int32 = 31 + data := &ValidGenLtInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtInt32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtInt32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int32 = 31 + + data := &ValidatorLtInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtInt64Pointer(b *testing.B) { + var validInput int64 = 31 + data := &ValidGenLtInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtInt64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtInt64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int64 = 31 + + data := &ValidatorLtInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUintPointer(b *testing.B) { + var validInput uint = 31 + data := &ValidGenLtUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtUintPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUintPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint = 31 + + data := &ValidatorLtUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUint8Pointer(b *testing.B) { + var validInput uint8 = 31 + data := &ValidGenLtUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtUint8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUint8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint8 = 31 + + data := &ValidatorLtUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUint16Pointer(b *testing.B) { + var validInput uint16 = 31 + data := &ValidGenLtUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtUint16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUint16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint16 = 31 + + data := &ValidatorLtUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUint32Pointer(b *testing.B) { + var validInput uint32 = 31 + data := &ValidGenLtUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtUint32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUint32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint32 = 31 + + data := &ValidatorLtUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtUint64Pointer(b *testing.B) { + var validInput uint64 = 31 + data := &ValidGenLtUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtUint64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtUint64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint64 = 31 + + data := &ValidatorLtUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtFloat32Pointer(b *testing.B) { + var validInput float32 = 12.33 + data := &ValidGenLtFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtFloat32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtFloat32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float32 = 12.33 + + data := &ValidatorLtFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLtFloat64Pointer(b *testing.B) { + var validInput float64 = 12.33 + data := &ValidGenLtFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLtFloat64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLtFloat64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float64 = 12.33 + + data := &ValidatorLtFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteIntPointer(b *testing.B) { + var validInput int = 32 + data := &ValidGenLteIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteIntPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteIntPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int = 32 + + data := &ValidatorLteIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteInt8Pointer(b *testing.B) { + var validInput int8 = 32 + data := &ValidGenLteInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteInt8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteInt8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int8 = 32 + + data := &ValidatorLteInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteInt16Pointer(b *testing.B) { + var validInput int16 = 32 + data := &ValidGenLteInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteInt16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteInt16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int16 = 32 + + data := &ValidatorLteInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteInt32Pointer(b *testing.B) { + var validInput int32 = 32 + data := &ValidGenLteInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteInt32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteInt32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int32 = 32 + + data := &ValidatorLteInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteInt64Pointer(b *testing.B) { + var validInput int64 = 32 + data := &ValidGenLteInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteInt64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteInt64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int64 = 32 + + data := &ValidatorLteInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUintPointer(b *testing.B) { + var validInput uint = 32 + data := &ValidGenLteUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteUintPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUintPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint = 32 + + data := &ValidatorLteUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUint8Pointer(b *testing.B) { + var validInput uint8 = 32 + data := &ValidGenLteUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteUint8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUint8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint8 = 32 + + data := &ValidatorLteUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUint16Pointer(b *testing.B) { + var validInput uint16 = 32 + data := &ValidGenLteUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteUint16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUint16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint16 = 32 + + data := &ValidatorLteUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUint32Pointer(b *testing.B) { + var validInput uint32 = 32 + data := &ValidGenLteUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteUint32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUint32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint32 = 32 + + data := &ValidatorLteUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteUint64Pointer(b *testing.B) { + var validInput uint64 = 32 + data := &ValidGenLteUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteUint64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteUint64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint64 = 32 + + data := &ValidatorLteUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteFloat32Pointer(b *testing.B) { + var validInput float32 = 12.34 + data := &ValidGenLteFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteFloat32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteFloat32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float32 = 12.34 + + data := &ValidatorLteFloat32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLteFloat64Pointer(b *testing.B) { + var validInput float64 = 12.34 + data := &ValidGenLteFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLteFloat64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLteFloat64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput float64 = 12.34 + + data := &ValidatorLteFloat64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinStringPointer(b *testing.B) { + var validInput string = "abcde" + data := &ValidGenMinStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "abcde" + + data := &ValidatorMinStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinStringSlicePointer(b *testing.B) { + var validInput []string = []string{"abc", "def"} + data := &ValidGenMinStringSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinStringSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinStringSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []string = []string{"abc", "def"} + + data := &ValidatorMinStringSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinIntSlicePointer(b *testing.B) { + var validInput []int = []int{65, 67} + data := &ValidGenMinIntSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinIntSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinIntSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int = []int{65, 67} + + data := &ValidatorMinIntSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt8SlicePointer(b *testing.B) { + var validInput []int8 = []int8{65, 67} + data := &ValidGenMinInt8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinInt8SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt8SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int8 = []int8{65, 67} + + data := &ValidatorMinInt8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt16SlicePointer(b *testing.B) { + var validInput []int16 = []int16{65, 67} + data := &ValidGenMinInt16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinInt16SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt16SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int16 = []int16{65, 67} + + data := &ValidatorMinInt16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt32SlicePointer(b *testing.B) { + var validInput []int32 = []int32{65, 67} + data := &ValidGenMinInt32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinInt32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int32 = []int32{65, 67} + + data := &ValidatorMinInt32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt64SlicePointer(b *testing.B) { + var validInput []int64 = []int64{65, 67} + data := &ValidGenMinInt64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinInt64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int64 = []int64{65, 67} + + data := &ValidatorMinInt64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUintSlicePointer(b *testing.B) { + var validInput []uint = []uint{65, 67} + data := &ValidGenMinUintSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUintSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUintSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint = []uint{65, 67} + + data := &ValidatorMinUintSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint8SlicePointer(b *testing.B) { + var validInput []uint8 = []uint8{65, 67} + data := &ValidGenMinUint8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUint8SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint8SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint8 = []uint8{65, 67} + + data := &ValidatorMinUint8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint16SlicePointer(b *testing.B) { + var validInput []uint16 = []uint16{65, 67} + data := &ValidGenMinUint16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUint16SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint16SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint16 = []uint16{65, 67} + + data := &ValidatorMinUint16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint32SlicePointer(b *testing.B) { + var validInput []uint32 = []uint32{65, 67} + data := &ValidGenMinUint32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUint32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint32 = []uint32{65, 67} + + data := &ValidatorMinUint32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint64SlicePointer(b *testing.B) { + var validInput []uint64 = []uint64{65, 67} + data := &ValidGenMinUint64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUint64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint64 = []uint64{65, 67} + + data := &ValidatorMinUint64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinFloat32SlicePointer(b *testing.B) { + var validInput []float32 = []float32{65.65, 67.67} + data := &ValidGenMinFloat32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinFloat32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinFloat32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []float32 = []float32{65.65, 67.67} + + data := &ValidatorMinFloat32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinFloat64SlicePointer(b *testing.B) { + var validInput []float64 = []float64{65.65, 67.67} + data := &ValidGenMinFloat64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinFloat64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinFloat64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []float64 = []float64{65.65, 67.67} + + data := &ValidatorMinFloat64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinBoolSlicePointer(b *testing.B) { + var validInput []bool = []bool{true, false} + data := &ValidGenMinBoolSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinBoolSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinBoolSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []bool = []bool{true, false} + + data := &ValidatorMinBoolSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinStringMapPointer(b *testing.B) { + var validInput map[string]string = map[string]string{"a": "1", "b": "2"} + data := &ValidGenMinStringMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinStringMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinStringMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[string]string = map[string]string{"a": "1", "b": "2"} + + data := &ValidatorMinStringMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinIntMapPointer(b *testing.B) { + var validInput map[int]int = map[int]int{1: 65, 2: 67} + data := &ValidGenMinIntMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinIntMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinIntMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int]int = map[int]int{1: 65, 2: 67} + + data := &ValidatorMinIntMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt8MapPointer(b *testing.B) { + var validInput map[int8]int8 = map[int8]int8{1: 65, 2: 67} + data := &ValidGenMinInt8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinInt8MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt8MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int8]int8 = map[int8]int8{1: 65, 2: 67} + + data := &ValidatorMinInt8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt16MapPointer(b *testing.B) { + var validInput map[int16]int16 = map[int16]int16{1: 65, 2: 67} + data := &ValidGenMinInt16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinInt16MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt16MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int16]int16 = map[int16]int16{1: 65, 2: 67} + + data := &ValidatorMinInt16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt32MapPointer(b *testing.B) { + var validInput map[int32]int32 = map[int32]int32{1: 65, 2: 67} + data := &ValidGenMinInt32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinInt32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int32]int32 = map[int32]int32{1: 65, 2: 67} + + data := &ValidatorMinInt32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinInt64MapPointer(b *testing.B) { + var validInput map[int64]int64 = map[int64]int64{1: 65, 2: 67} + data := &ValidGenMinInt64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinInt64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinInt64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int64]int64 = map[int64]int64{1: 65, 2: 67} + + data := &ValidatorMinInt64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUintMapPointer(b *testing.B) { + var validInput map[uint]uint = map[uint]uint{1: 65, 2: 67} + data := &ValidGenMinUintMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUintMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUintMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint]uint = map[uint]uint{1: 65, 2: 67} + + data := &ValidatorMinUintMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint8MapPointer(b *testing.B) { + var validInput map[uint8]uint8 = map[uint8]uint8{1: 65, 2: 67} + data := &ValidGenMinUint8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUint8MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint8MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint8]uint8 = map[uint8]uint8{1: 65, 2: 67} + + data := &ValidatorMinUint8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint16MapPointer(b *testing.B) { + var validInput map[uint16]uint16 = map[uint16]uint16{1: 65, 2: 67} + data := &ValidGenMinUint16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUint16MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint16MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint16]uint16 = map[uint16]uint16{1: 65, 2: 67} + + data := &ValidatorMinUint16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint32MapPointer(b *testing.B) { + var validInput map[uint32]uint32 = map[uint32]uint32{1: 65, 2: 67} + data := &ValidGenMinUint32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUint32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint32]uint32 = map[uint32]uint32{1: 65, 2: 67} + + data := &ValidatorMinUint32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinUint64MapPointer(b *testing.B) { + var validInput map[uint64]uint64 = map[uint64]uint64{1: 65, 2: 67} + data := &ValidGenMinUint64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinUint64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinUint64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint64]uint64 = map[uint64]uint64{1: 65, 2: 67} + + data := &ValidatorMinUint64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinFloat32MapPointer(b *testing.B) { + var validInput map[float32]float32 = map[float32]float32{1: 65.65, 2: 67.67} + data := &ValidGenMinFloat32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinFloat32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinFloat32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[float32]float32 = map[float32]float32{1: 65.65, 2: 67.67} + + data := &ValidatorMinFloat32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinFloat64MapPointer(b *testing.B) { + var validInput map[float64]float64 = map[float64]float64{1: 65.65, 2: 67.67} + data := &ValidGenMinFloat64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinFloat64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinFloat64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[float64]float64 = map[float64]float64{1: 65.65, 2: 67.67} + + data := &ValidatorMinFloat64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMinBoolMapPointer(b *testing.B) { + var validInput map[bool]bool = map[bool]bool{true: true, false: false} + data := &ValidGenMinBoolMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMinBoolMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMinBoolMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[bool]bool = map[bool]bool{true: true, false: false} + + data := &ValidatorMinBoolMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxStringPointer(b *testing.B) { + var validInput string = "abc" + data := &ValidGenMaxStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "abc" + + data := &ValidatorMaxStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxStringSlicePointer(b *testing.B) { + var validInput []string = []string{"abc", "def"} + data := &ValidGenMaxStringSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxStringSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxStringSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []string = []string{"abc", "def"} + + data := &ValidatorMaxStringSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxIntSlicePointer(b *testing.B) { + var validInput []int = []int{65, 67} + data := &ValidGenMaxIntSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxIntSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxIntSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int = []int{65, 67} + + data := &ValidatorMaxIntSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt8SlicePointer(b *testing.B) { + var validInput []int8 = []int8{65, 67} + data := &ValidGenMaxInt8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxInt8SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt8SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int8 = []int8{65, 67} + + data := &ValidatorMaxInt8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt16SlicePointer(b *testing.B) { + var validInput []int16 = []int16{65, 67} + data := &ValidGenMaxInt16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxInt16SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt16SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int16 = []int16{65, 67} + + data := &ValidatorMaxInt16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt32SlicePointer(b *testing.B) { + var validInput []int32 = []int32{65, 67} + data := &ValidGenMaxInt32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxInt32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int32 = []int32{65, 67} + + data := &ValidatorMaxInt32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt64SlicePointer(b *testing.B) { + var validInput []int64 = []int64{65, 67} + data := &ValidGenMaxInt64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxInt64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int64 = []int64{65, 67} + + data := &ValidatorMaxInt64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUintSlicePointer(b *testing.B) { + var validInput []uint = []uint{65, 67} + data := &ValidGenMaxUintSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUintSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUintSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint = []uint{65, 67} + + data := &ValidatorMaxUintSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint8SlicePointer(b *testing.B) { + var validInput []uint8 = []uint8{65, 67} + data := &ValidGenMaxUint8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUint8SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint8SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint8 = []uint8{65, 67} + + data := &ValidatorMaxUint8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint16SlicePointer(b *testing.B) { + var validInput []uint16 = []uint16{65, 67} + data := &ValidGenMaxUint16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUint16SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint16SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint16 = []uint16{65, 67} + + data := &ValidatorMaxUint16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint32SlicePointer(b *testing.B) { + var validInput []uint32 = []uint32{65, 67} + data := &ValidGenMaxUint32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUint32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint32 = []uint32{65, 67} + + data := &ValidatorMaxUint32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint64SlicePointer(b *testing.B) { + var validInput []uint64 = []uint64{65, 67} + data := &ValidGenMaxUint64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUint64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint64 = []uint64{65, 67} + + data := &ValidatorMaxUint64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxFloat32SlicePointer(b *testing.B) { + var validInput []float32 = []float32{65.65, 67.67} + data := &ValidGenMaxFloat32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxFloat32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxFloat32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []float32 = []float32{65.65, 67.67} + + data := &ValidatorMaxFloat32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxFloat64SlicePointer(b *testing.B) { + var validInput []float64 = []float64{65.65, 67.67} + data := &ValidGenMaxFloat64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxFloat64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxFloat64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []float64 = []float64{65.65, 67.67} + + data := &ValidatorMaxFloat64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxBoolSlicePointer(b *testing.B) { + var validInput []bool = []bool{true, false} + data := &ValidGenMaxBoolSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxBoolSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxBoolSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []bool = []bool{true, false} + + data := &ValidatorMaxBoolSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxStringMapPointer(b *testing.B) { + var validInput map[string]string = map[string]string{"a": "1", "b": "2"} + data := &ValidGenMaxStringMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxStringMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxStringMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[string]string = map[string]string{"a": "1", "b": "2"} + + data := &ValidatorMaxStringMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxIntMapPointer(b *testing.B) { + var validInput map[int]int = map[int]int{1: 65, 2: 67} + data := &ValidGenMaxIntMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxIntMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxIntMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int]int = map[int]int{1: 65, 2: 67} + + data := &ValidatorMaxIntMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt8MapPointer(b *testing.B) { + var validInput map[int8]int8 = map[int8]int8{1: 65, 2: 67} + data := &ValidGenMaxInt8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxInt8MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt8MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int8]int8 = map[int8]int8{1: 65, 2: 67} + + data := &ValidatorMaxInt8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt16MapPointer(b *testing.B) { + var validInput map[int16]int16 = map[int16]int16{1: 65, 2: 67} + data := &ValidGenMaxInt16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxInt16MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt16MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int16]int16 = map[int16]int16{1: 65, 2: 67} + + data := &ValidatorMaxInt16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt32MapPointer(b *testing.B) { + var validInput map[int32]int32 = map[int32]int32{1: 65, 2: 67} + data := &ValidGenMaxInt32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxInt32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int32]int32 = map[int32]int32{1: 65, 2: 67} + + data := &ValidatorMaxInt32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxInt64MapPointer(b *testing.B) { + var validInput map[int64]int64 = map[int64]int64{1: 65, 2: 67} + data := &ValidGenMaxInt64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxInt64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxInt64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int64]int64 = map[int64]int64{1: 65, 2: 67} + + data := &ValidatorMaxInt64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUintMapPointer(b *testing.B) { + var validInput map[uint]uint = map[uint]uint{1: 65, 2: 67} + data := &ValidGenMaxUintMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUintMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUintMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint]uint = map[uint]uint{1: 65, 2: 67} + + data := &ValidatorMaxUintMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint8MapPointer(b *testing.B) { + var validInput map[uint8]uint8 = map[uint8]uint8{1: 65, 2: 67} + data := &ValidGenMaxUint8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUint8MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint8MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint8]uint8 = map[uint8]uint8{1: 65, 2: 67} + + data := &ValidatorMaxUint8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint16MapPointer(b *testing.B) { + var validInput map[uint16]uint16 = map[uint16]uint16{1: 65, 2: 67} + data := &ValidGenMaxUint16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUint16MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint16MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint16]uint16 = map[uint16]uint16{1: 65, 2: 67} + + data := &ValidatorMaxUint16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint32MapPointer(b *testing.B) { + var validInput map[uint32]uint32 = map[uint32]uint32{1: 65, 2: 67} + data := &ValidGenMaxUint32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUint32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint32]uint32 = map[uint32]uint32{1: 65, 2: 67} + + data := &ValidatorMaxUint32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxUint64MapPointer(b *testing.B) { + var validInput map[uint64]uint64 = map[uint64]uint64{1: 65, 2: 67} + data := &ValidGenMaxUint64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxUint64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxUint64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint64]uint64 = map[uint64]uint64{1: 65, 2: 67} + + data := &ValidatorMaxUint64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxFloat32MapPointer(b *testing.B) { + var validInput map[float32]float32 = map[float32]float32{1: 65.65, 2: 67.67} + data := &ValidGenMaxFloat32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxFloat32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxFloat32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[float32]float32 = map[float32]float32{1: 65.65, 2: 67.67} + + data := &ValidatorMaxFloat32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxFloat64MapPointer(b *testing.B) { + var validInput map[float64]float64 = map[float64]float64{1: 65.65, 2: 67.67} + data := &ValidGenMaxFloat64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxFloat64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxFloat64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[float64]float64 = map[float64]float64{1: 65.65, 2: 67.67} + + data := &ValidatorMaxFloat64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenMaxBoolMapPointer(b *testing.B) { + var validInput map[bool]bool = map[bool]bool{true: true} + data := &ValidGenMaxBoolMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenMaxBoolMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorMaxBoolMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[bool]bool = map[bool]bool{true: true} + + data := &ValidatorMaxBoolMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenEq_ignore_caseStringPointer(b *testing.B) { + var validInput string = "AbCdE" + data := &ValidGenEq_ignore_caseStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenEq_ignore_caseStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorEq_ignore_caseStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "AbCdE" + + data := &ValidatorEq_ignore_caseStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenNeq_ignore_caseStringPointer(b *testing.B) { + var validInput string = "a1b2c3" + data := &ValidGenNeq_ignore_caseStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenNeq_ignore_caseStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorNeq_ignore_caseStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "a1b2c3" + + data := &ValidatorNeq_ignore_caseStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenStringPointer(b *testing.B) { + var validInput string = "ab" + data := &ValidGenLenStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "ab" + + data := &ValidatorLenStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenStringSlicePointer(b *testing.B) { + var validInput []string = []string{"abc", "def"} + data := &ValidGenLenStringSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenStringSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenStringSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []string = []string{"abc", "def"} + + data := &ValidatorLenStringSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenIntSlicePointer(b *testing.B) { + var validInput []int = []int{65, 67} + data := &ValidGenLenIntSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenIntSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenIntSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int = []int{65, 67} + + data := &ValidatorLenIntSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt8SlicePointer(b *testing.B) { + var validInput []int8 = []int8{65, 67} + data := &ValidGenLenInt8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenInt8SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt8SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int8 = []int8{65, 67} + + data := &ValidatorLenInt8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt16SlicePointer(b *testing.B) { + var validInput []int16 = []int16{65, 67} + data := &ValidGenLenInt16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenInt16SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt16SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int16 = []int16{65, 67} + + data := &ValidatorLenInt16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt32SlicePointer(b *testing.B) { + var validInput []int32 = []int32{65, 67} + data := &ValidGenLenInt32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenInt32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int32 = []int32{65, 67} + + data := &ValidatorLenInt32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt64SlicePointer(b *testing.B) { + var validInput []int64 = []int64{65, 67} + data := &ValidGenLenInt64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenInt64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []int64 = []int64{65, 67} + + data := &ValidatorLenInt64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUintSlicePointer(b *testing.B) { + var validInput []uint = []uint{65, 67} + data := &ValidGenLenUintSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUintSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUintSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint = []uint{65, 67} + + data := &ValidatorLenUintSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint8SlicePointer(b *testing.B) { + var validInput []uint8 = []uint8{65, 67} + data := &ValidGenLenUint8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUint8SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint8SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint8 = []uint8{65, 67} + + data := &ValidatorLenUint8SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint16SlicePointer(b *testing.B) { + var validInput []uint16 = []uint16{65, 67} + data := &ValidGenLenUint16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUint16SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint16SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint16 = []uint16{65, 67} + + data := &ValidatorLenUint16SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint32SlicePointer(b *testing.B) { + var validInput []uint32 = []uint32{65, 67} + data := &ValidGenLenUint32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUint32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint32 = []uint32{65, 67} + + data := &ValidatorLenUint32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint64SlicePointer(b *testing.B) { + var validInput []uint64 = []uint64{65, 67} + data := &ValidGenLenUint64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUint64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []uint64 = []uint64{65, 67} + + data := &ValidatorLenUint64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenFloat32SlicePointer(b *testing.B) { + var validInput []float32 = []float32{65.65, 67.67} + data := &ValidGenLenFloat32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenFloat32SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenFloat32SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []float32 = []float32{65.65, 67.67} + + data := &ValidatorLenFloat32SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenFloat64SlicePointer(b *testing.B) { + var validInput []float64 = []float64{65.65, 67.67} + data := &ValidGenLenFloat64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenFloat64SlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenFloat64SlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []float64 = []float64{65.65, 67.67} + + data := &ValidatorLenFloat64SlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenBoolSlicePointer(b *testing.B) { + var validInput []bool = []bool{true, false} + data := &ValidGenLenBoolSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenBoolSlicePointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenBoolSlicePointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput []bool = []bool{true, false} + + data := &ValidatorLenBoolSlicePointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenStringMapPointer(b *testing.B) { + var validInput map[string]string = map[string]string{"a": "1", "b": "2"} + data := &ValidGenLenStringMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenStringMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenStringMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[string]string = map[string]string{"a": "1", "b": "2"} + + data := &ValidatorLenStringMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenIntMapPointer(b *testing.B) { + var validInput map[int]int = map[int]int{1: 65, 2: 67} + data := &ValidGenLenIntMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenIntMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenIntMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int]int = map[int]int{1: 65, 2: 67} + + data := &ValidatorLenIntMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt8MapPointer(b *testing.B) { + var validInput map[int8]int8 = map[int8]int8{1: 65, 2: 67} + data := &ValidGenLenInt8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenInt8MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt8MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int8]int8 = map[int8]int8{1: 65, 2: 67} + + data := &ValidatorLenInt8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt16MapPointer(b *testing.B) { + var validInput map[int16]int16 = map[int16]int16{1: 65, 2: 67} + data := &ValidGenLenInt16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenInt16MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt16MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int16]int16 = map[int16]int16{1: 65, 2: 67} + + data := &ValidatorLenInt16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt32MapPointer(b *testing.B) { + var validInput map[int32]int32 = map[int32]int32{1: 65, 2: 67} + data := &ValidGenLenInt32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenInt32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int32]int32 = map[int32]int32{1: 65, 2: 67} + + data := &ValidatorLenInt32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenInt64MapPointer(b *testing.B) { + var validInput map[int64]int64 = map[int64]int64{1: 65, 2: 67} + data := &ValidGenLenInt64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenInt64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenInt64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[int64]int64 = map[int64]int64{1: 65, 2: 67} + + data := &ValidatorLenInt64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUintMapPointer(b *testing.B) { + var validInput map[uint]uint = map[uint]uint{1: 65, 2: 67} + data := &ValidGenLenUintMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUintMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUintMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint]uint = map[uint]uint{1: 65, 2: 67} + + data := &ValidatorLenUintMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint8MapPointer(b *testing.B) { + var validInput map[uint8]uint8 = map[uint8]uint8{1: 65, 2: 67} + data := &ValidGenLenUint8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUint8MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint8MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint8]uint8 = map[uint8]uint8{1: 65, 2: 67} + + data := &ValidatorLenUint8MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint16MapPointer(b *testing.B) { + var validInput map[uint16]uint16 = map[uint16]uint16{1: 65, 2: 67} + data := &ValidGenLenUint16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUint16MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint16MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint16]uint16 = map[uint16]uint16{1: 65, 2: 67} + + data := &ValidatorLenUint16MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint32MapPointer(b *testing.B) { + var validInput map[uint32]uint32 = map[uint32]uint32{1: 65, 2: 67} + data := &ValidGenLenUint32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUint32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint32]uint32 = map[uint32]uint32{1: 65, 2: 67} + + data := &ValidatorLenUint32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenUint64MapPointer(b *testing.B) { + var validInput map[uint64]uint64 = map[uint64]uint64{1: 65, 2: 67} + data := &ValidGenLenUint64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenUint64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenUint64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[uint64]uint64 = map[uint64]uint64{1: 65, 2: 67} + + data := &ValidatorLenUint64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenFloat32MapPointer(b *testing.B) { + var validInput map[float32]float32 = map[float32]float32{1: 65.65, 2: 67.67} + data := &ValidGenLenFloat32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenFloat32MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenFloat32MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[float32]float32 = map[float32]float32{1: 65.65, 2: 67.67} + + data := &ValidatorLenFloat32MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenFloat64MapPointer(b *testing.B) { + var validInput map[float64]float64 = map[float64]float64{1: 65.65, 2: 67.67} + data := &ValidGenLenFloat64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenFloat64MapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenFloat64MapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[float64]float64 = map[float64]float64{1: 65.65, 2: 67.67} + + data := &ValidatorLenFloat64MapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenLenBoolMapPointer(b *testing.B) { + var validInput map[bool]bool = map[bool]bool{true: true, false: false} + data := &ValidGenLenBoolMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenLenBoolMapPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorLenBoolMapPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput map[bool]bool = map[bool]bool{true: true, false: false} + + data := &ValidatorLenBoolMapPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInStringPointer(b *testing.B) { + var validInput string = "cd" + data := &ValidGenInStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInStringPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInStringPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput string = "cd" + + data := &ValidatorInStringPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInIntPointer(b *testing.B) { + var validInput int = 34 + data := &ValidGenInIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInIntPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInIntPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int = 34 + + data := &ValidatorInIntPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInInt8Pointer(b *testing.B) { + var validInput int8 = 34 + data := &ValidGenInInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInInt8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInInt8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int8 = 34 + + data := &ValidatorInInt8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInInt16Pointer(b *testing.B) { + var validInput int16 = 34 + data := &ValidGenInInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInInt16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInInt16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int16 = 34 + + data := &ValidatorInInt16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInInt32Pointer(b *testing.B) { + var validInput int32 = 34 + data := &ValidGenInInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInInt32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInInt32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int32 = 34 + + data := &ValidatorInInt32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInInt64Pointer(b *testing.B) { + var validInput int64 = 34 + data := &ValidGenInInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInInt64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInInt64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput int64 = 34 + + data := &ValidatorInInt64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUintPointer(b *testing.B) { + var validInput uint = 34 + data := &ValidGenInUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInUintPointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUintPointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint = 34 + + data := &ValidatorInUintPointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUint8Pointer(b *testing.B) { + var validInput uint8 = 34 + data := &ValidGenInUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInUint8PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUint8Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint8 = 34 + + data := &ValidatorInUint8PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUint16Pointer(b *testing.B) { + var validInput uint16 = 34 + data := &ValidGenInUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInUint16PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUint16Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint16 = 34 + + data := &ValidatorInUint16PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUint32Pointer(b *testing.B) { + var validInput uint32 = 34 + data := &ValidGenInUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInUint32PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUint32Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint32 = 34 + + data := &ValidatorInUint32PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} + +func BenchmarkValidGenInUint64Pointer(b *testing.B) { + var validInput uint64 = 34 + data := &ValidGenInUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := ValidGenInUint64PointerStructValidate(data); len(err) > 0 { + b.FailNow() + } + } +} + +func BenchmarkValidatorInUint64Pointer(b *testing.B) { + var validate *validator.Validate + + validate = validator.New(validator.WithRequiredStructEnabled()) + + var validInput uint64 = 34 + + data := &ValidatorInUint64PointerStruct{ + Field: &validInput, + } + + for b.Loop() { + if err := validate.Struct(data); err != nil { + b.FailNow() + } + } +} diff --git a/tests/cmpbenchtests/generated_tests/validator__.go b/tests/cmpbenchtests/generated_tests/validator__.go index 907f5e3..5684e0a 100755 --- a/tests/cmpbenchtests/generated_tests/validator__.go +++ b/tests/cmpbenchtests/generated_tests/validator__.go @@ -6,6 +6,3170 @@ import ( "github.com/opencodeco/validgen/types" ) +func ValidGenEmailStringPointerStructValidate(obj *ValidGenEmailStringPointerStruct) []error { + var errs []error + if !(obj.Field != nil && types.IsValidEmail(*obj.Field)) { + errs = append(errs, types.NewValidationError("Field must be a valid email")) + } + return errs +} +func ValidGenEmailStringStructValidate(obj *ValidGenEmailStringStruct) []error { + var errs []error + if !(types.IsValidEmail(obj.Field)) { + errs = append(errs, types.NewValidationError("Field must be a valid email")) + } + return errs +} +func ValidGenEqBoolPointerStructValidate(obj *ValidGenEqBoolPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == true) { + errs = append(errs, types.NewValidationError("Field must be equal to true")) + } + return errs +} +func ValidGenEqBoolStructValidate(obj *ValidGenEqBoolStruct) []error { + var errs []error + if !(obj.Field == true) { + errs = append(errs, types.NewValidationError("Field must be equal to true")) + } + return errs +} +func ValidGenEqFloat32PointerStructValidate(obj *ValidGenEqFloat32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 12.34) { + errs = append(errs, types.NewValidationError("Field must be equal to 12.34")) + } + return errs +} +func ValidGenEqFloat32StructValidate(obj *ValidGenEqFloat32Struct) []error { + var errs []error + if !(obj.Field == 12.34) { + errs = append(errs, types.NewValidationError("Field must be equal to 12.34")) + } + return errs +} +func ValidGenEqFloat64PointerStructValidate(obj *ValidGenEqFloat64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 12.34) { + errs = append(errs, types.NewValidationError("Field must be equal to 12.34")) + } + return errs +} +func ValidGenEqFloat64StructValidate(obj *ValidGenEqFloat64Struct) []error { + var errs []error + if !(obj.Field == 12.34) { + errs = append(errs, types.NewValidationError("Field must be equal to 12.34")) + } + return errs +} +func ValidGenEqInt16PointerStructValidate(obj *ValidGenEqInt16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqInt16StructValidate(obj *ValidGenEqInt16Struct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqInt32PointerStructValidate(obj *ValidGenEqInt32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqInt32StructValidate(obj *ValidGenEqInt32Struct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqInt64PointerStructValidate(obj *ValidGenEqInt64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqInt64StructValidate(obj *ValidGenEqInt64Struct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqInt8PointerStructValidate(obj *ValidGenEqInt8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqInt8StructValidate(obj *ValidGenEqInt8Struct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqIntPointerStructValidate(obj *ValidGenEqIntPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqIntStructValidate(obj *ValidGenEqIntStruct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqStringPointerStructValidate(obj *ValidGenEqStringPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == "abcde") { + errs = append(errs, types.NewValidationError("Field must be equal to 'abcde'")) + } + return errs +} +func ValidGenEqStringStructValidate(obj *ValidGenEqStringStruct) []error { + var errs []error + if !(obj.Field == "abcde") { + errs = append(errs, types.NewValidationError("Field must be equal to 'abcde'")) + } + return errs +} +func ValidGenEqUint16PointerStructValidate(obj *ValidGenEqUint16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqUint16StructValidate(obj *ValidGenEqUint16Struct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqUint32PointerStructValidate(obj *ValidGenEqUint32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqUint32StructValidate(obj *ValidGenEqUint32Struct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqUint64PointerStructValidate(obj *ValidGenEqUint64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqUint64StructValidate(obj *ValidGenEqUint64Struct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqUint8PointerStructValidate(obj *ValidGenEqUint8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqUint8StructValidate(obj *ValidGenEqUint8Struct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqUintPointerStructValidate(obj *ValidGenEqUintPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEqUintStructValidate(obj *ValidGenEqUintStruct) []error { + var errs []error + if !(obj.Field == 32) { + errs = append(errs, types.NewValidationError("Field must be equal to 32")) + } + return errs +} +func ValidGenEq_ignore_caseStringPointerStructValidate(obj *ValidGenEq_ignore_caseStringPointerStruct) []error { + var errs []error + if !(obj.Field != nil && types.EqualFold(*obj.Field, "abcde")) { + errs = append(errs, types.NewValidationError("Field must be equal to 'abcde'")) + } + return errs +} +func ValidGenEq_ignore_caseStringStructValidate(obj *ValidGenEq_ignore_caseStringStruct) []error { + var errs []error + if !(types.EqualFold(obj.Field, "abcde")) { + errs = append(errs, types.NewValidationError("Field must be equal to 'abcde'")) + } + return errs +} +func ValidGenGtFloat32PointerStructValidate(obj *ValidGenGtFloat32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 12.34) { + errs = append(errs, types.NewValidationError("Field must be > 12.34")) + } + return errs +} +func ValidGenGtFloat32StructValidate(obj *ValidGenGtFloat32Struct) []error { + var errs []error + if !(obj.Field > 12.34) { + errs = append(errs, types.NewValidationError("Field must be > 12.34")) + } + return errs +} +func ValidGenGtFloat64PointerStructValidate(obj *ValidGenGtFloat64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 12.34) { + errs = append(errs, types.NewValidationError("Field must be > 12.34")) + } + return errs +} +func ValidGenGtFloat64StructValidate(obj *ValidGenGtFloat64Struct) []error { + var errs []error + if !(obj.Field > 12.34) { + errs = append(errs, types.NewValidationError("Field must be > 12.34")) + } + return errs +} +func ValidGenGtInt16PointerStructValidate(obj *ValidGenGtInt16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtInt16StructValidate(obj *ValidGenGtInt16Struct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtInt32PointerStructValidate(obj *ValidGenGtInt32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtInt32StructValidate(obj *ValidGenGtInt32Struct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtInt64PointerStructValidate(obj *ValidGenGtInt64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtInt64StructValidate(obj *ValidGenGtInt64Struct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtInt8PointerStructValidate(obj *ValidGenGtInt8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtInt8StructValidate(obj *ValidGenGtInt8Struct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtIntPointerStructValidate(obj *ValidGenGtIntPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtIntStructValidate(obj *ValidGenGtIntStruct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUint16PointerStructValidate(obj *ValidGenGtUint16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUint16StructValidate(obj *ValidGenGtUint16Struct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUint32PointerStructValidate(obj *ValidGenGtUint32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUint32StructValidate(obj *ValidGenGtUint32Struct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUint64PointerStructValidate(obj *ValidGenGtUint64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUint64StructValidate(obj *ValidGenGtUint64Struct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUint8PointerStructValidate(obj *ValidGenGtUint8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUint8StructValidate(obj *ValidGenGtUint8Struct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUintPointerStructValidate(obj *ValidGenGtUintPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGtUintStructValidate(obj *ValidGenGtUintStruct) []error { + var errs []error + if !(obj.Field > 32) { + errs = append(errs, types.NewValidationError("Field must be > 32")) + } + return errs +} +func ValidGenGteFloat32PointerStructValidate(obj *ValidGenGteFloat32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 12.34) { + errs = append(errs, types.NewValidationError("Field must be >= 12.34")) + } + return errs +} +func ValidGenGteFloat32StructValidate(obj *ValidGenGteFloat32Struct) []error { + var errs []error + if !(obj.Field >= 12.34) { + errs = append(errs, types.NewValidationError("Field must be >= 12.34")) + } + return errs +} +func ValidGenGteFloat64PointerStructValidate(obj *ValidGenGteFloat64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 12.34) { + errs = append(errs, types.NewValidationError("Field must be >= 12.34")) + } + return errs +} +func ValidGenGteFloat64StructValidate(obj *ValidGenGteFloat64Struct) []error { + var errs []error + if !(obj.Field >= 12.34) { + errs = append(errs, types.NewValidationError("Field must be >= 12.34")) + } + return errs +} +func ValidGenGteInt16PointerStructValidate(obj *ValidGenGteInt16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteInt16StructValidate(obj *ValidGenGteInt16Struct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteInt32PointerStructValidate(obj *ValidGenGteInt32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteInt32StructValidate(obj *ValidGenGteInt32Struct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteInt64PointerStructValidate(obj *ValidGenGteInt64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteInt64StructValidate(obj *ValidGenGteInt64Struct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteInt8PointerStructValidate(obj *ValidGenGteInt8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteInt8StructValidate(obj *ValidGenGteInt8Struct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteIntPointerStructValidate(obj *ValidGenGteIntPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteIntStructValidate(obj *ValidGenGteIntStruct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUint16PointerStructValidate(obj *ValidGenGteUint16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUint16StructValidate(obj *ValidGenGteUint16Struct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUint32PointerStructValidate(obj *ValidGenGteUint32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUint32StructValidate(obj *ValidGenGteUint32Struct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUint64PointerStructValidate(obj *ValidGenGteUint64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUint64StructValidate(obj *ValidGenGteUint64Struct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUint8PointerStructValidate(obj *ValidGenGteUint8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUint8StructValidate(obj *ValidGenGteUint8Struct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUintPointerStructValidate(obj *ValidGenGteUintPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenGteUintStructValidate(obj *ValidGenGteUintStruct) []error { + var errs []error + if !(obj.Field >= 32) { + errs = append(errs, types.NewValidationError("Field must be >= 32")) + } + return errs +} +func ValidGenInInt16PointerStructValidate(obj *ValidGenInInt16PointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInInt16StructValidate(obj *ValidGenInInt16Struct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInInt32PointerStructValidate(obj *ValidGenInInt32PointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInInt32StructValidate(obj *ValidGenInInt32Struct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInInt64PointerStructValidate(obj *ValidGenInInt64PointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInInt64StructValidate(obj *ValidGenInInt64Struct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInInt8PointerStructValidate(obj *ValidGenInInt8PointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInInt8StructValidate(obj *ValidGenInInt8Struct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInIntPointerStructValidate(obj *ValidGenInIntPointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInIntStructValidate(obj *ValidGenInIntStruct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInStringPointerStructValidate(obj *ValidGenInStringPointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == "ab") || (obj.Field != nil && *obj.Field == "cd") || (obj.Field != nil && *obj.Field == "ef")) { + errs = append(errs, types.NewValidationError("Field must be one of 'ab' 'cd' 'ef'")) + } + return errs +} +func ValidGenInStringStructValidate(obj *ValidGenInStringStruct) []error { + var errs []error + if !(obj.Field == "ab" || obj.Field == "cd" || obj.Field == "ef") { + errs = append(errs, types.NewValidationError("Field must be one of 'ab' 'cd' 'ef'")) + } + return errs +} +func ValidGenInUint16PointerStructValidate(obj *ValidGenInUint16PointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInUint16StructValidate(obj *ValidGenInUint16Struct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInUint32PointerStructValidate(obj *ValidGenInUint32PointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInUint32StructValidate(obj *ValidGenInUint32Struct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInUint64PointerStructValidate(obj *ValidGenInUint64PointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInUint64StructValidate(obj *ValidGenInUint64Struct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInUint8PointerStructValidate(obj *ValidGenInUint8PointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInUint8StructValidate(obj *ValidGenInUint8Struct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInUintPointerStructValidate(obj *ValidGenInUintPointerStruct) []error { + var errs []error + if !((obj.Field != nil && *obj.Field == 12) || (obj.Field != nil && *obj.Field == 34) || (obj.Field != nil && *obj.Field == 56)) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenInUintStructValidate(obj *ValidGenInUintStruct) []error { + var errs []error + if !(obj.Field == 12 || obj.Field == 34 || obj.Field == 56) { + errs = append(errs, types.NewValidationError("Field must be one of '12' '34' '56'")) + } + return errs +} +func ValidGenLenBoolMapPointerStructValidate(obj *ValidGenLenBoolMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenBoolMapStructValidate(obj *ValidGenLenBoolMapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenBoolSlicePointerStructValidate(obj *ValidGenLenBoolSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenBoolSliceStructValidate(obj *ValidGenLenBoolSliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenFloat32MapPointerStructValidate(obj *ValidGenLenFloat32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenFloat32MapStructValidate(obj *ValidGenLenFloat32MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenFloat32SlicePointerStructValidate(obj *ValidGenLenFloat32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenFloat32SliceStructValidate(obj *ValidGenLenFloat32SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenFloat64MapPointerStructValidate(obj *ValidGenLenFloat64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenFloat64MapStructValidate(obj *ValidGenLenFloat64MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenFloat64SlicePointerStructValidate(obj *ValidGenLenFloat64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenFloat64SliceStructValidate(obj *ValidGenLenFloat64SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt16MapPointerStructValidate(obj *ValidGenLenInt16MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt16MapStructValidate(obj *ValidGenLenInt16MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt16SlicePointerStructValidate(obj *ValidGenLenInt16SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt16SliceStructValidate(obj *ValidGenLenInt16SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt32MapPointerStructValidate(obj *ValidGenLenInt32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt32MapStructValidate(obj *ValidGenLenInt32MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt32SlicePointerStructValidate(obj *ValidGenLenInt32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt32SliceStructValidate(obj *ValidGenLenInt32SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt64MapPointerStructValidate(obj *ValidGenLenInt64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt64MapStructValidate(obj *ValidGenLenInt64MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt64SlicePointerStructValidate(obj *ValidGenLenInt64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt64SliceStructValidate(obj *ValidGenLenInt64SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt8MapPointerStructValidate(obj *ValidGenLenInt8MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt8MapStructValidate(obj *ValidGenLenInt8MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt8SlicePointerStructValidate(obj *ValidGenLenInt8SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenInt8SliceStructValidate(obj *ValidGenLenInt8SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenIntMapPointerStructValidate(obj *ValidGenLenIntMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenIntMapStructValidate(obj *ValidGenLenIntMapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenIntSlicePointerStructValidate(obj *ValidGenLenIntSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenIntSliceStructValidate(obj *ValidGenLenIntSliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenStringMapPointerStructValidate(obj *ValidGenLenStringMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenStringMapStructValidate(obj *ValidGenLenStringMapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenStringPointerStructValidate(obj *ValidGenLenStringPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field length must be 2")) + } + return errs +} +func ValidGenLenStringSlicePointerStructValidate(obj *ValidGenLenStringSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenStringSliceStructValidate(obj *ValidGenLenStringSliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenStringStructValidate(obj *ValidGenLenStringStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field length must be 2")) + } + return errs +} +func ValidGenLenUint16MapPointerStructValidate(obj *ValidGenLenUint16MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint16MapStructValidate(obj *ValidGenLenUint16MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint16SlicePointerStructValidate(obj *ValidGenLenUint16SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint16SliceStructValidate(obj *ValidGenLenUint16SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint32MapPointerStructValidate(obj *ValidGenLenUint32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint32MapStructValidate(obj *ValidGenLenUint32MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint32SlicePointerStructValidate(obj *ValidGenLenUint32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint32SliceStructValidate(obj *ValidGenLenUint32SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint64MapPointerStructValidate(obj *ValidGenLenUint64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint64MapStructValidate(obj *ValidGenLenUint64MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint64SlicePointerStructValidate(obj *ValidGenLenUint64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint64SliceStructValidate(obj *ValidGenLenUint64SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint8MapPointerStructValidate(obj *ValidGenLenUint8MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint8MapStructValidate(obj *ValidGenLenUint8MapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint8SlicePointerStructValidate(obj *ValidGenLenUint8SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUint8SliceStructValidate(obj *ValidGenLenUint8SliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUintMapPointerStructValidate(obj *ValidGenLenUintMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUintMapStructValidate(obj *ValidGenLenUintMapStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUintSlicePointerStructValidate(obj *ValidGenLenUintSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLenUintSliceStructValidate(obj *ValidGenLenUintSliceStruct) []error { + var errs []error + if !(len(obj.Field) == 2) { + errs = append(errs, types.NewValidationError("Field must have exactly 2 elements")) + } + return errs +} +func ValidGenLtFloat32PointerStructValidate(obj *ValidGenLtFloat32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 12.34) { + errs = append(errs, types.NewValidationError("Field must be < 12.34")) + } + return errs +} +func ValidGenLtFloat32StructValidate(obj *ValidGenLtFloat32Struct) []error { + var errs []error + if !(obj.Field < 12.34) { + errs = append(errs, types.NewValidationError("Field must be < 12.34")) + } + return errs +} +func ValidGenLtFloat64PointerStructValidate(obj *ValidGenLtFloat64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 12.34) { + errs = append(errs, types.NewValidationError("Field must be < 12.34")) + } + return errs +} +func ValidGenLtFloat64StructValidate(obj *ValidGenLtFloat64Struct) []error { + var errs []error + if !(obj.Field < 12.34) { + errs = append(errs, types.NewValidationError("Field must be < 12.34")) + } + return errs +} +func ValidGenLtInt16PointerStructValidate(obj *ValidGenLtInt16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtInt16StructValidate(obj *ValidGenLtInt16Struct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtInt32PointerStructValidate(obj *ValidGenLtInt32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtInt32StructValidate(obj *ValidGenLtInt32Struct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtInt64PointerStructValidate(obj *ValidGenLtInt64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtInt64StructValidate(obj *ValidGenLtInt64Struct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtInt8PointerStructValidate(obj *ValidGenLtInt8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtInt8StructValidate(obj *ValidGenLtInt8Struct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtIntPointerStructValidate(obj *ValidGenLtIntPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtIntStructValidate(obj *ValidGenLtIntStruct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUint16PointerStructValidate(obj *ValidGenLtUint16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUint16StructValidate(obj *ValidGenLtUint16Struct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUint32PointerStructValidate(obj *ValidGenLtUint32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUint32StructValidate(obj *ValidGenLtUint32Struct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUint64PointerStructValidate(obj *ValidGenLtUint64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUint64StructValidate(obj *ValidGenLtUint64Struct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUint8PointerStructValidate(obj *ValidGenLtUint8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUint8StructValidate(obj *ValidGenLtUint8Struct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUintPointerStructValidate(obj *ValidGenLtUintPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLtUintStructValidate(obj *ValidGenLtUintStruct) []error { + var errs []error + if !(obj.Field < 32) { + errs = append(errs, types.NewValidationError("Field must be < 32")) + } + return errs +} +func ValidGenLteFloat32PointerStructValidate(obj *ValidGenLteFloat32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 12.34) { + errs = append(errs, types.NewValidationError("Field must be <= 12.34")) + } + return errs +} +func ValidGenLteFloat32StructValidate(obj *ValidGenLteFloat32Struct) []error { + var errs []error + if !(obj.Field <= 12.34) { + errs = append(errs, types.NewValidationError("Field must be <= 12.34")) + } + return errs +} +func ValidGenLteFloat64PointerStructValidate(obj *ValidGenLteFloat64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 12.34) { + errs = append(errs, types.NewValidationError("Field must be <= 12.34")) + } + return errs +} +func ValidGenLteFloat64StructValidate(obj *ValidGenLteFloat64Struct) []error { + var errs []error + if !(obj.Field <= 12.34) { + errs = append(errs, types.NewValidationError("Field must be <= 12.34")) + } + return errs +} +func ValidGenLteInt16PointerStructValidate(obj *ValidGenLteInt16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteInt16StructValidate(obj *ValidGenLteInt16Struct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteInt32PointerStructValidate(obj *ValidGenLteInt32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteInt32StructValidate(obj *ValidGenLteInt32Struct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteInt64PointerStructValidate(obj *ValidGenLteInt64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteInt64StructValidate(obj *ValidGenLteInt64Struct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteInt8PointerStructValidate(obj *ValidGenLteInt8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteInt8StructValidate(obj *ValidGenLteInt8Struct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteIntPointerStructValidate(obj *ValidGenLteIntPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteIntStructValidate(obj *ValidGenLteIntStruct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUint16PointerStructValidate(obj *ValidGenLteUint16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUint16StructValidate(obj *ValidGenLteUint16Struct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUint32PointerStructValidate(obj *ValidGenLteUint32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUint32StructValidate(obj *ValidGenLteUint32Struct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUint64PointerStructValidate(obj *ValidGenLteUint64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUint64StructValidate(obj *ValidGenLteUint64Struct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUint8PointerStructValidate(obj *ValidGenLteUint8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUint8StructValidate(obj *ValidGenLteUint8Struct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUintPointerStructValidate(obj *ValidGenLteUintPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenLteUintStructValidate(obj *ValidGenLteUintStruct) []error { + var errs []error + if !(obj.Field <= 32) { + errs = append(errs, types.NewValidationError("Field must be <= 32")) + } + return errs +} +func ValidGenMaxBoolMapPointerStructValidate(obj *ValidGenMaxBoolMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 1) { + errs = append(errs, types.NewValidationError("Field must have at most 1 elements")) + } + return errs +} +func ValidGenMaxBoolMapStructValidate(obj *ValidGenMaxBoolMapStruct) []error { + var errs []error + if !(len(obj.Field) <= 1) { + errs = append(errs, types.NewValidationError("Field must have at most 1 elements")) + } + return errs +} +func ValidGenMaxBoolSlicePointerStructValidate(obj *ValidGenMaxBoolSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxBoolSliceStructValidate(obj *ValidGenMaxBoolSliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxFloat32MapPointerStructValidate(obj *ValidGenMaxFloat32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxFloat32MapStructValidate(obj *ValidGenMaxFloat32MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxFloat32SlicePointerStructValidate(obj *ValidGenMaxFloat32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxFloat32SliceStructValidate(obj *ValidGenMaxFloat32SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxFloat64MapPointerStructValidate(obj *ValidGenMaxFloat64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxFloat64MapStructValidate(obj *ValidGenMaxFloat64MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxFloat64SlicePointerStructValidate(obj *ValidGenMaxFloat64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxFloat64SliceStructValidate(obj *ValidGenMaxFloat64SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt16MapPointerStructValidate(obj *ValidGenMaxInt16MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt16MapStructValidate(obj *ValidGenMaxInt16MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt16SlicePointerStructValidate(obj *ValidGenMaxInt16SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt16SliceStructValidate(obj *ValidGenMaxInt16SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt32MapPointerStructValidate(obj *ValidGenMaxInt32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt32MapStructValidate(obj *ValidGenMaxInt32MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt32SlicePointerStructValidate(obj *ValidGenMaxInt32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt32SliceStructValidate(obj *ValidGenMaxInt32SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt64MapPointerStructValidate(obj *ValidGenMaxInt64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt64MapStructValidate(obj *ValidGenMaxInt64MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt64SlicePointerStructValidate(obj *ValidGenMaxInt64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt64SliceStructValidate(obj *ValidGenMaxInt64SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt8MapPointerStructValidate(obj *ValidGenMaxInt8MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt8MapStructValidate(obj *ValidGenMaxInt8MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt8SlicePointerStructValidate(obj *ValidGenMaxInt8SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxInt8SliceStructValidate(obj *ValidGenMaxInt8SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxIntMapPointerStructValidate(obj *ValidGenMaxIntMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxIntMapStructValidate(obj *ValidGenMaxIntMapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxIntSlicePointerStructValidate(obj *ValidGenMaxIntSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxIntSliceStructValidate(obj *ValidGenMaxIntSliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxStringMapPointerStructValidate(obj *ValidGenMaxStringMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxStringMapStructValidate(obj *ValidGenMaxStringMapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxStringPointerStructValidate(obj *ValidGenMaxStringPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 3) { + errs = append(errs, types.NewValidationError("Field length must be <= 3")) + } + return errs +} +func ValidGenMaxStringSlicePointerStructValidate(obj *ValidGenMaxStringSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxStringSliceStructValidate(obj *ValidGenMaxStringSliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxStringStructValidate(obj *ValidGenMaxStringStruct) []error { + var errs []error + if !(len(obj.Field) <= 3) { + errs = append(errs, types.NewValidationError("Field length must be <= 3")) + } + return errs +} +func ValidGenMaxUint16MapPointerStructValidate(obj *ValidGenMaxUint16MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint16MapStructValidate(obj *ValidGenMaxUint16MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint16SlicePointerStructValidate(obj *ValidGenMaxUint16SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint16SliceStructValidate(obj *ValidGenMaxUint16SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint32MapPointerStructValidate(obj *ValidGenMaxUint32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint32MapStructValidate(obj *ValidGenMaxUint32MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint32SlicePointerStructValidate(obj *ValidGenMaxUint32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint32SliceStructValidate(obj *ValidGenMaxUint32SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint64MapPointerStructValidate(obj *ValidGenMaxUint64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint64MapStructValidate(obj *ValidGenMaxUint64MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint64SlicePointerStructValidate(obj *ValidGenMaxUint64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint64SliceStructValidate(obj *ValidGenMaxUint64SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint8MapPointerStructValidate(obj *ValidGenMaxUint8MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint8MapStructValidate(obj *ValidGenMaxUint8MapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint8SlicePointerStructValidate(obj *ValidGenMaxUint8SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUint8SliceStructValidate(obj *ValidGenMaxUint8SliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUintMapPointerStructValidate(obj *ValidGenMaxUintMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUintMapStructValidate(obj *ValidGenMaxUintMapStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUintSlicePointerStructValidate(obj *ValidGenMaxUintSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMaxUintSliceStructValidate(obj *ValidGenMaxUintSliceStruct) []error { + var errs []error + if !(len(obj.Field) <= 2) { + errs = append(errs, types.NewValidationError("Field must have at most 2 elements")) + } + return errs +} +func ValidGenMinBoolMapPointerStructValidate(obj *ValidGenMinBoolMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinBoolMapStructValidate(obj *ValidGenMinBoolMapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinBoolSlicePointerStructValidate(obj *ValidGenMinBoolSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinBoolSliceStructValidate(obj *ValidGenMinBoolSliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinFloat32MapPointerStructValidate(obj *ValidGenMinFloat32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinFloat32MapStructValidate(obj *ValidGenMinFloat32MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinFloat32SlicePointerStructValidate(obj *ValidGenMinFloat32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinFloat32SliceStructValidate(obj *ValidGenMinFloat32SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinFloat64MapPointerStructValidate(obj *ValidGenMinFloat64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinFloat64MapStructValidate(obj *ValidGenMinFloat64MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinFloat64SlicePointerStructValidate(obj *ValidGenMinFloat64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinFloat64SliceStructValidate(obj *ValidGenMinFloat64SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt16MapPointerStructValidate(obj *ValidGenMinInt16MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt16MapStructValidate(obj *ValidGenMinInt16MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt16SlicePointerStructValidate(obj *ValidGenMinInt16SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt16SliceStructValidate(obj *ValidGenMinInt16SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt32MapPointerStructValidate(obj *ValidGenMinInt32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt32MapStructValidate(obj *ValidGenMinInt32MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt32SlicePointerStructValidate(obj *ValidGenMinInt32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt32SliceStructValidate(obj *ValidGenMinInt32SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt64MapPointerStructValidate(obj *ValidGenMinInt64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt64MapStructValidate(obj *ValidGenMinInt64MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt64SlicePointerStructValidate(obj *ValidGenMinInt64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt64SliceStructValidate(obj *ValidGenMinInt64SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt8MapPointerStructValidate(obj *ValidGenMinInt8MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt8MapStructValidate(obj *ValidGenMinInt8MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt8SlicePointerStructValidate(obj *ValidGenMinInt8SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinInt8SliceStructValidate(obj *ValidGenMinInt8SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinIntMapPointerStructValidate(obj *ValidGenMinIntMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinIntMapStructValidate(obj *ValidGenMinIntMapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinIntSlicePointerStructValidate(obj *ValidGenMinIntSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinIntSliceStructValidate(obj *ValidGenMinIntSliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinStringMapPointerStructValidate(obj *ValidGenMinStringMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinStringMapStructValidate(obj *ValidGenMinStringMapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinStringPointerStructValidate(obj *ValidGenMinStringPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 5) { + errs = append(errs, types.NewValidationError("Field length must be >= 5")) + } + return errs +} +func ValidGenMinStringSlicePointerStructValidate(obj *ValidGenMinStringSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinStringSliceStructValidate(obj *ValidGenMinStringSliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinStringStructValidate(obj *ValidGenMinStringStruct) []error { + var errs []error + if !(len(obj.Field) >= 5) { + errs = append(errs, types.NewValidationError("Field length must be >= 5")) + } + return errs +} +func ValidGenMinUint16MapPointerStructValidate(obj *ValidGenMinUint16MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint16MapStructValidate(obj *ValidGenMinUint16MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint16SlicePointerStructValidate(obj *ValidGenMinUint16SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint16SliceStructValidate(obj *ValidGenMinUint16SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint32MapPointerStructValidate(obj *ValidGenMinUint32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint32MapStructValidate(obj *ValidGenMinUint32MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint32SlicePointerStructValidate(obj *ValidGenMinUint32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint32SliceStructValidate(obj *ValidGenMinUint32SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint64MapPointerStructValidate(obj *ValidGenMinUint64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint64MapStructValidate(obj *ValidGenMinUint64MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint64SlicePointerStructValidate(obj *ValidGenMinUint64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint64SliceStructValidate(obj *ValidGenMinUint64SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint8MapPointerStructValidate(obj *ValidGenMinUint8MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint8MapStructValidate(obj *ValidGenMinUint8MapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint8SlicePointerStructValidate(obj *ValidGenMinUint8SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUint8SliceStructValidate(obj *ValidGenMinUint8SliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUintMapPointerStructValidate(obj *ValidGenMinUintMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUintMapStructValidate(obj *ValidGenMinUintMapStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUintSlicePointerStructValidate(obj *ValidGenMinUintSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenMinUintSliceStructValidate(obj *ValidGenMinUintSliceStruct) []error { + var errs []error + if !(len(obj.Field) >= 2) { + errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) + } + return errs +} +func ValidGenNeqBoolPointerStructValidate(obj *ValidGenNeqBoolPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != true) { + errs = append(errs, types.NewValidationError("Field must not be equal to true")) + } + return errs +} +func ValidGenNeqBoolStructValidate(obj *ValidGenNeqBoolStruct) []error { + var errs []error + if !(obj.Field != true) { + errs = append(errs, types.NewValidationError("Field must not be equal to true")) + } + return errs +} +func ValidGenNeqFloat32PointerStructValidate(obj *ValidGenNeqFloat32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 12.34) { + errs = append(errs, types.NewValidationError("Field must not be equal to 12.34")) + } + return errs +} +func ValidGenNeqFloat32StructValidate(obj *ValidGenNeqFloat32Struct) []error { + var errs []error + if !(obj.Field != 12.34) { + errs = append(errs, types.NewValidationError("Field must not be equal to 12.34")) + } + return errs +} +func ValidGenNeqFloat64PointerStructValidate(obj *ValidGenNeqFloat64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 12.34) { + errs = append(errs, types.NewValidationError("Field must not be equal to 12.34")) + } + return errs +} +func ValidGenNeqFloat64StructValidate(obj *ValidGenNeqFloat64Struct) []error { + var errs []error + if !(obj.Field != 12.34) { + errs = append(errs, types.NewValidationError("Field must not be equal to 12.34")) + } + return errs +} +func ValidGenNeqInt16PointerStructValidate(obj *ValidGenNeqInt16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqInt16StructValidate(obj *ValidGenNeqInt16Struct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqInt32PointerStructValidate(obj *ValidGenNeqInt32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqInt32StructValidate(obj *ValidGenNeqInt32Struct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqInt64PointerStructValidate(obj *ValidGenNeqInt64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqInt64StructValidate(obj *ValidGenNeqInt64Struct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqInt8PointerStructValidate(obj *ValidGenNeqInt8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqInt8StructValidate(obj *ValidGenNeqInt8Struct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqIntPointerStructValidate(obj *ValidGenNeqIntPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqIntStructValidate(obj *ValidGenNeqIntStruct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqStringPointerStructValidate(obj *ValidGenNeqStringPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != "abcde") { + errs = append(errs, types.NewValidationError("Field must not be equal to 'abcde'")) + } + return errs +} +func ValidGenNeqStringStructValidate(obj *ValidGenNeqStringStruct) []error { + var errs []error + if !(obj.Field != "abcde") { + errs = append(errs, types.NewValidationError("Field must not be equal to 'abcde'")) + } + return errs +} +func ValidGenNeqUint16PointerStructValidate(obj *ValidGenNeqUint16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqUint16StructValidate(obj *ValidGenNeqUint16Struct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqUint32PointerStructValidate(obj *ValidGenNeqUint32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqUint32StructValidate(obj *ValidGenNeqUint32Struct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqUint64PointerStructValidate(obj *ValidGenNeqUint64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqUint64StructValidate(obj *ValidGenNeqUint64Struct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqUint8PointerStructValidate(obj *ValidGenNeqUint8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqUint8StructValidate(obj *ValidGenNeqUint8Struct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqUintPointerStructValidate(obj *ValidGenNeqUintPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeqUintStructValidate(obj *ValidGenNeqUintStruct) []error { + var errs []error + if !(obj.Field != 32) { + errs = append(errs, types.NewValidationError("Field must not be equal to 32")) + } + return errs +} +func ValidGenNeq_ignore_caseStringPointerStructValidate(obj *ValidGenNeq_ignore_caseStringPointerStruct) []error { + var errs []error + if !(obj.Field != nil && !types.EqualFold(*obj.Field, "abcde")) { + errs = append(errs, types.NewValidationError("Field must not be equal to 'abcde'")) + } + return errs +} +func ValidGenNeq_ignore_caseStringStructValidate(obj *ValidGenNeq_ignore_caseStringStruct) []error { + var errs []error + if !(!types.EqualFold(obj.Field, "abcde")) { + errs = append(errs, types.NewValidationError("Field must not be equal to 'abcde'")) + } + return errs +} +func ValidGenRequiredBoolArrayPointerStructValidate(obj *ValidGenRequiredBoolArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredBoolMapPointerStructValidate(obj *ValidGenRequiredBoolMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredBoolMapStructValidate(obj *ValidGenRequiredBoolMapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredBoolPointerStructValidate(obj *ValidGenRequiredBoolPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != false) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredBoolSlicePointerStructValidate(obj *ValidGenRequiredBoolSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredBoolSliceStructValidate(obj *ValidGenRequiredBoolSliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredBoolStructValidate(obj *ValidGenRequiredBoolStruct) []error { + var errs []error + if !(obj.Field != false) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredFloat32ArrayPointerStructValidate(obj *ValidGenRequiredFloat32ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat32MapPointerStructValidate(obj *ValidGenRequiredFloat32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat32MapStructValidate(obj *ValidGenRequiredFloat32MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat32PointerStructValidate(obj *ValidGenRequiredFloat32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredFloat32SlicePointerStructValidate(obj *ValidGenRequiredFloat32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat32SliceStructValidate(obj *ValidGenRequiredFloat32SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat32StructValidate(obj *ValidGenRequiredFloat32Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredFloat64ArrayPointerStructValidate(obj *ValidGenRequiredFloat64ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat64MapPointerStructValidate(obj *ValidGenRequiredFloat64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat64MapStructValidate(obj *ValidGenRequiredFloat64MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat64PointerStructValidate(obj *ValidGenRequiredFloat64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredFloat64SlicePointerStructValidate(obj *ValidGenRequiredFloat64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat64SliceStructValidate(obj *ValidGenRequiredFloat64SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredFloat64StructValidate(obj *ValidGenRequiredFloat64Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredInt16ArrayPointerStructValidate(obj *ValidGenRequiredInt16ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt16MapPointerStructValidate(obj *ValidGenRequiredInt16MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt16MapStructValidate(obj *ValidGenRequiredInt16MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt16PointerStructValidate(obj *ValidGenRequiredInt16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredInt16SlicePointerStructValidate(obj *ValidGenRequiredInt16SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt16SliceStructValidate(obj *ValidGenRequiredInt16SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt16StructValidate(obj *ValidGenRequiredInt16Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredInt32ArrayPointerStructValidate(obj *ValidGenRequiredInt32ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt32MapPointerStructValidate(obj *ValidGenRequiredInt32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt32MapStructValidate(obj *ValidGenRequiredInt32MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt32PointerStructValidate(obj *ValidGenRequiredInt32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredInt32SlicePointerStructValidate(obj *ValidGenRequiredInt32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt32SliceStructValidate(obj *ValidGenRequiredInt32SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt32StructValidate(obj *ValidGenRequiredInt32Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredInt64ArrayPointerStructValidate(obj *ValidGenRequiredInt64ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt64MapPointerStructValidate(obj *ValidGenRequiredInt64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt64MapStructValidate(obj *ValidGenRequiredInt64MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt64PointerStructValidate(obj *ValidGenRequiredInt64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredInt64SlicePointerStructValidate(obj *ValidGenRequiredInt64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt64SliceStructValidate(obj *ValidGenRequiredInt64SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt64StructValidate(obj *ValidGenRequiredInt64Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredInt8ArrayPointerStructValidate(obj *ValidGenRequiredInt8ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt8MapPointerStructValidate(obj *ValidGenRequiredInt8MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt8MapStructValidate(obj *ValidGenRequiredInt8MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt8PointerStructValidate(obj *ValidGenRequiredInt8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredInt8SlicePointerStructValidate(obj *ValidGenRequiredInt8SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt8SliceStructValidate(obj *ValidGenRequiredInt8SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredInt8StructValidate(obj *ValidGenRequiredInt8Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredIntArrayPointerStructValidate(obj *ValidGenRequiredIntArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredIntMapPointerStructValidate(obj *ValidGenRequiredIntMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredIntMapStructValidate(obj *ValidGenRequiredIntMapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredIntPointerStructValidate(obj *ValidGenRequiredIntPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredIntSlicePointerStructValidate(obj *ValidGenRequiredIntSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredIntSliceStructValidate(obj *ValidGenRequiredIntSliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredIntStructValidate(obj *ValidGenRequiredIntStruct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredStringArrayPointerStructValidate(obj *ValidGenRequiredStringArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredStringMapPointerStructValidate(obj *ValidGenRequiredStringMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredStringMapStructValidate(obj *ValidGenRequiredStringMapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredStringPointerStructValidate(obj *ValidGenRequiredStringPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != "") { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredStringSlicePointerStructValidate(obj *ValidGenRequiredStringSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredStringSliceStructValidate(obj *ValidGenRequiredStringSliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredStringStructValidate(obj *ValidGenRequiredStringStruct) []error { + var errs []error + if !(obj.Field != "") { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUint16ArrayPointerStructValidate(obj *ValidGenRequiredUint16ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint16MapPointerStructValidate(obj *ValidGenRequiredUint16MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint16MapStructValidate(obj *ValidGenRequiredUint16MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint16PointerStructValidate(obj *ValidGenRequiredUint16PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUint16SlicePointerStructValidate(obj *ValidGenRequiredUint16SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint16SliceStructValidate(obj *ValidGenRequiredUint16SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint16StructValidate(obj *ValidGenRequiredUint16Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUint32ArrayPointerStructValidate(obj *ValidGenRequiredUint32ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint32MapPointerStructValidate(obj *ValidGenRequiredUint32MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint32MapStructValidate(obj *ValidGenRequiredUint32MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint32PointerStructValidate(obj *ValidGenRequiredUint32PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUint32SlicePointerStructValidate(obj *ValidGenRequiredUint32SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint32SliceStructValidate(obj *ValidGenRequiredUint32SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint32StructValidate(obj *ValidGenRequiredUint32Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUint64ArrayPointerStructValidate(obj *ValidGenRequiredUint64ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint64MapPointerStructValidate(obj *ValidGenRequiredUint64MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint64MapStructValidate(obj *ValidGenRequiredUint64MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint64PointerStructValidate(obj *ValidGenRequiredUint64PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUint64SlicePointerStructValidate(obj *ValidGenRequiredUint64SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint64SliceStructValidate(obj *ValidGenRequiredUint64SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint64StructValidate(obj *ValidGenRequiredUint64Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUint8ArrayPointerStructValidate(obj *ValidGenRequiredUint8ArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint8MapPointerStructValidate(obj *ValidGenRequiredUint8MapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint8MapStructValidate(obj *ValidGenRequiredUint8MapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint8PointerStructValidate(obj *ValidGenRequiredUint8PointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUint8SlicePointerStructValidate(obj *ValidGenRequiredUint8SlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint8SliceStructValidate(obj *ValidGenRequiredUint8SliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUint8StructValidate(obj *ValidGenRequiredUint8Struct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUintArrayPointerStructValidate(obj *ValidGenRequiredUintArrayPointerStruct) []error { + var errs []error + if !(obj.Field != nil) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUintMapPointerStructValidate(obj *ValidGenRequiredUintMapPointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUintMapStructValidate(obj *ValidGenRequiredUintMapStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUintPointerStructValidate(obj *ValidGenRequiredUintPointerStruct) []error { + var errs []error + if !(obj.Field != nil && *obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} +func ValidGenRequiredUintSlicePointerStructValidate(obj *ValidGenRequiredUintSlicePointerStruct) []error { + var errs []error + if !(obj.Field != nil && len(*obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUintSliceStructValidate(obj *ValidGenRequiredUintSliceStruct) []error { + var errs []error + if !(len(obj.Field) != 0) { + errs = append(errs, types.NewValidationError("Field must not be empty")) + } + return errs +} +func ValidGenRequiredUintStructValidate(obj *ValidGenRequiredUintStruct) []error { + var errs []error + if !(obj.Field != 0) { + errs = append(errs, types.NewValidationError("Field is required")) + } + return errs +} func ValidGenStringEmailStructValidate(obj *ValidGenStringEmailStruct) []error { var errs []error if !(types.IsValidEmail(obj.Field)) { From 2f9c8ed65fc759bc93e60e3d4d206fcd60c190c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Wed, 29 Oct 2025 11:28:28 -0300 Subject: [PATCH 20/31] chore: use fmt instead of log --- testgen/generate_cmp_perf_tests.go | 32 ++++++++++++------- testgen/generate_function_code_tests.go | 30 ++++++++++------- testgen/generate_tests.go | 24 +++++++++++--- testgen/generate_validation_code_tests.go | 30 ++++++++++------- testgen/generate_validation_types_tests.go | 26 +++++++++------ tests/endtoend/generated_numeric_int_tests.go | 2 +- 6 files changed, 96 insertions(+), 48 deletions(-) diff --git a/testgen/generate_cmp_perf_tests.go b/testgen/generate_cmp_perf_tests.go index f02b772..c919c27 100644 --- a/testgen/generate_cmp_perf_tests.go +++ b/testgen/generate_cmp_perf_tests.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "go/format" - "log" "os" "strings" "text/template" @@ -27,29 +26,36 @@ type CmpBenchTest struct { ValidInput string } -func generateComparativePerformanceTests() { - generateComparativePerformanceTest("cmp_perf_no_pointer_tests.tpl", "generated_cmp_perf_no_pointer_test.go", false) - generateComparativePerformanceTest("cmp_perf_pointer_tests.tpl", "generated_cmp_perf_pointer_test.go", true) +func generateComparativePerformanceTests() error { + if err := generateComparativePerformanceTest("cmp_perf_no_pointer_tests.tpl", "generated_cmp_perf_no_pointer_test.go", false); err != nil { + return err + } + + if err := generateComparativePerformanceTest("cmp_perf_pointer_tests.tpl", "generated_cmp_perf_pointer_test.go", true); err != nil { + return err + } + + return nil } -func generateComparativePerformanceTest(tpl, dest string, pointer bool) { - log.Printf("Generating comparative performance tests file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) +func generateComparativePerformanceTest(tpl, dest string, pointer bool) error { + fmt.Printf("Generating comparative performance tests file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) benchTests := CmpBenchTests{} for _, typeVal := range typesValidation { if typeVal.validatorTag == "" { - log.Printf("Skipping tag %s: go-validator tag not defined\n", typeVal.tag) + fmt.Printf("Skipping tag %s: go-validator tag not defined\n", typeVal.tag) continue } for _, testCase := range typeVal.testCases { if testCase.excludeIf&cmpBenchTests != 0 { - log.Printf("Skipping test: tag %s type %s\n", typeVal.tag, testCase.typeClass) + fmt.Printf("Skipping test: tag %s type %s\n", typeVal.tag, testCase.typeClass) continue } if testCase.excludeIf&noPointer != 0 && !pointer { - log.Printf("Skipping no pointer: tag %s type %s\n", typeVal.tag, testCase.typeClass) + fmt.Printf("Skipping no pointer: tag %s type %s\n", typeVal.tag, testCase.typeClass) continue } @@ -86,13 +92,15 @@ func generateComparativePerformanceTest(tpl, dest string, pointer bool) { } } - log.Printf("%d test cases were generated\n", len(benchTests.Tests)) + fmt.Printf("%d test cases were generated\n", len(benchTests.Tests)) if err := benchTests.GenerateFile(tpl, dest); err != nil { - log.Fatalf("error generating comparative performance tests file %s", err) + return fmt.Errorf("error generating comparative performance tests file %s", err) } - log.Println("Generating done") + fmt.Println("Generating done") + + return nil } func (cbt *CmpBenchTests) GenerateFile(tplFile, output string) error { diff --git a/testgen/generate_function_code_tests.go b/testgen/generate_function_code_tests.go index dfb6df5..0b20f83 100644 --- a/testgen/generate_function_code_tests.go +++ b/testgen/generate_function_code_tests.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "go/format" - "log" "os" "text/template" @@ -34,13 +33,20 @@ type FunctionCodeTestField struct { Tag string } -func generateFunctionCodeUnitTests() { - generateFunctionCodeTestsFile("function_code_test.tpl", "generated_function_code_no_pointer_test.go", false) - generateFunctionCodeTestsFile("function_code_test.tpl", "generated_function_code_pointer_test.go", true) +func generateFunctionCodeUnitTests() error { + if err := generateFunctionCodeUnitTest("function_code_test.tpl", "generated_function_code_no_pointer_test.go", false); err != nil { + return err + } + + if err := generateFunctionCodeUnitTest("function_code_test.tpl", "generated_function_code_pointer_test.go", true); err != nil { + return err + } + + return nil } -func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { - log.Printf("Generating function code test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) +func generateFunctionCodeUnitTest(tpl, dest string, pointer bool) error { + fmt.Printf("Generating function code test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) funcName := "TestBuildFunctionCode" if pointer { @@ -66,7 +72,7 @@ func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { for _, toGenerate := range typeValidation.testCases { if toGenerate.excludeIf&noPointer != 0 && !pointer { - log.Printf("Skipping no pointer: tag %s type %s\n", typeValidation.tag, toGenerate.typeClass) + fmt.Printf("Skipping no pointer: tag %s type %s\n", typeValidation.tag, toGenerate.typeClass) continue } @@ -84,7 +90,7 @@ func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { fieldName := "Field" + cases.Title(language.Und).String(typeValidation.tag) + fieldType.ToStringName() parsedValidation, err := analyzer.ParserValidation(validation) if err != nil { - log.Fatalf("failed to parse validation %q: %v", validation, err) + return fmt.Errorf("failed to parse validation %q: %v", validation, err) } newTest.Fields = append(newTest.Fields, FunctionCodeTestField{ @@ -110,7 +116,7 @@ func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { expectedCode, err := gv.BuildFuncValidatorCode() if err != nil { - log.Fatalf("failed to build function validator code for struct %q: %v", newTest.StructName, err) + return fmt.Errorf("failed to build function validator code for struct %q: %v", newTest.StructName, err) } newTest.ExpectedCode = expectedCode @@ -119,10 +125,12 @@ func generateFunctionCodeTestsFile(tpl, dest string, pointer bool) { } if err := testCases.GenerateFile(tpl, dest); err != nil { - log.Fatalf("error generating function code tests file %s", err) + return fmt.Errorf("generating function code tests file %s", err) } - log.Printf("Generating %s done\n", dest) + fmt.Printf("Generating %s done\n", dest) + + return nil } func (tc *FunctionCodeTestCases) GenerateFile(tplFile, output string) error { diff --git a/testgen/generate_tests.go b/testgen/generate_tests.go index 09d9c0f..ea41aaf 100644 --- a/testgen/generate_tests.go +++ b/testgen/generate_tests.go @@ -2,15 +2,31 @@ package main import ( "fmt" + "os" ) func main() { fmt.Println("Generating tests files") - generateValidationTypesEndToEndTests() - generateValidationCodeUnitTests() - generateFunctionCodeUnitTests() - generateComparativePerformanceTests() + if err := generateValidationTypesEndToEndTests(); err != nil { + fmt.Printf("error generating validation types end-to-end tests: %s", err) + os.Exit(1) + } + + if err := generateValidationCodeUnitTests(); err != nil { + fmt.Printf("error generating validation code unit tests: %s", err) + os.Exit(1) + } + + if err := generateFunctionCodeUnitTests(); err != nil { + fmt.Printf("error generating function code unit tests: %s", err) + os.Exit(1) + } + + if err := generateComparativePerformanceTests(); err != nil { + fmt.Printf("error generating comparative performance tests: %s", err) + os.Exit(1) + } fmt.Println("Generating done") } diff --git a/testgen/generate_validation_code_tests.go b/testgen/generate_validation_code_tests.go index 0e176b0..f5ab371 100644 --- a/testgen/generate_validation_code_tests.go +++ b/testgen/generate_validation_code_tests.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "go/format" - "log" "os" "text/template" @@ -28,13 +27,20 @@ type ValidationCodeTestCase struct { ExpectedCode string } -func generateValidationCodeUnitTests() { - generateValidationCodeTestsFile("build_validation_code_test.tpl", "generated_validation_code_no_pointer_test.go", false) - generateValidationCodeTestsFile("build_validation_code_test.tpl", "generated_validation_code_pointer_test.go", true) +func generateValidationCodeUnitTests() error { + if err := generateValidationCodeUnitTest("build_validation_code_test.tpl", "generated_validation_code_no_pointer_test.go", false); err != nil { + return err + } + + if err := generateValidationCodeUnitTest("build_validation_code_test.tpl", "generated_validation_code_pointer_test.go", true); err != nil { + return err + } + + return nil } -func generateValidationCodeTestsFile(tpl, dest string, pointer bool) { - log.Printf("Generating validation code test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) +func generateValidationCodeUnitTest(tpl, dest string, pointer bool) error { + fmt.Printf("Generating validation code test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) funcName := "TestBuildValidationCode" if pointer { @@ -48,7 +54,7 @@ func generateValidationCodeTestsFile(tpl, dest string, pointer bool) { for _, typeValidation := range typesValidation { for _, toGenerate := range typeValidation.testCases { if toGenerate.excludeIf&noPointer != 0 && !pointer { - log.Printf("Skipping no pointer: tag %s type %s\n", typeValidation.tag, toGenerate.typeClass) + fmt.Printf("Skipping no pointer: tag %s type %s\n", typeValidation.tag, toGenerate.typeClass) continue } @@ -68,11 +74,11 @@ func generateValidationCodeTestsFile(tpl, dest string, pointer bool) { gv := codegenerator.GenValidations{} parsedValidation, err := analyzer.ParserValidation(validation) if err != nil { - log.Fatalf("failed to parse validation %q: %v", validation, err) + return fmt.Errorf("failed to parse validation %q: %v", validation, err) } expectedValidationCode, err := gv.BuildValidationCode(fieldName, fieldType, []*analyzer.Validation{parsedValidation}) if err != nil { - log.Fatalf("failed to build validation code for %q: %v", fieldName, err) + return fmt.Errorf("failed to build validation code for %q: %v", fieldName, err) } testCases.Tests = append(testCases.Tests, ValidationCodeTestCase{ @@ -87,10 +93,12 @@ func generateValidationCodeTestsFile(tpl, dest string, pointer bool) { } if err := testCases.GenerateFile(tpl, dest); err != nil { - log.Fatalf("error generation validation code tests file %s", err) + return fmt.Errorf("error generating validation code tests file %s", err) } - log.Printf("Generating %s done\n", dest) + fmt.Printf("Generating %s done\n", dest) + + return nil } func (at *ValidationCodeTestCases) GenerateFile(tplFile, output string) error { diff --git a/testgen/generate_validation_types_tests.go b/testgen/generate_validation_types_tests.go index 1619d53..0bfa2f7 100644 --- a/testgen/generate_validation_types_tests.go +++ b/testgen/generate_validation_types_tests.go @@ -4,7 +4,6 @@ import ( "bytes" "fmt" "go/format" - "log" "os" "strings" "text/template" @@ -33,13 +32,20 @@ type TestCase struct { ErrorMessage string } -func generateValidationTypesEndToEndTests() { - generateValidationTypesTestsFile("no_pointer_tests.tpl", "generated_endtoend_no_pointer_tests.go", false) - generateValidationTypesTestsFile("pointer_tests.tpl", "generated_endtoend_pointer_tests.go", true) +func generateValidationTypesEndToEndTests() error { + if err := generateValidationTypesEndToEndTest("no_pointer_tests.tpl", "generated_endtoend_no_pointer_tests.go", false); err != nil { + return err + } + + if err := generateValidationTypesEndToEndTest("pointer_tests.tpl", "generated_endtoend_pointer_tests.go", true); err != nil { + return err + } + + return nil } -func generateValidationTypesTestsFile(tpl, dest string, pointer bool) { - log.Printf("Generating validation types test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) +func generateValidationTypesEndToEndTest(tpl, dest string, pointer bool) error { + fmt.Printf("Generating validation types test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) allTestsToGenerate := AllTestCasesToGenerate{} @@ -53,7 +59,7 @@ func generateValidationTypesTestsFile(tpl, dest string, pointer bool) { }) for _, toGenerate := range testCase.testCases { if toGenerate.excludeIf&noPointer != 0 && !pointer { - log.Printf("Skipping no pointer: tag %s type %s\n", testCase.tag, toGenerate.typeClass) + fmt.Printf("Skipping no pointer: tag %s type %s\n", testCase.tag, toGenerate.typeClass) continue } @@ -90,10 +96,12 @@ func generateValidationTypesTestsFile(tpl, dest string, pointer bool) { } if err := allTestsToGenerate.GenerateFile(tpl, dest); err != nil { - log.Fatalf("error generation validation types file %s", err) + return fmt.Errorf("generating validation types file %s", err) } - log.Printf("Generating %s done\n", dest) + fmt.Printf("Generating %s done\n", dest) + + return nil } func (tc *AllTestCasesToGenerate) GenerateFile(tplFile, output string) error { diff --git a/tests/endtoend/generated_numeric_int_tests.go b/tests/endtoend/generated_numeric_int_tests.go index 61ecbed..81d62c7 100644 --- a/tests/endtoend/generated_numeric_int_tests.go +++ b/tests/endtoend/generated_numeric_int_tests.go @@ -17,7 +17,7 @@ func numericIntTypeTests() { numericUint16Tests() numericUint32Tests() numericUint64Tests() - + log.Println("numeric int tests ok") } From fd656b3dc4951dd1ca8ee814fc4d5bef7113d23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Wed, 29 Oct 2025 11:42:36 -0300 Subject: [PATCH 21/31] refact: one func to exec template and format code --- testgen/execute_template.go | 37 ++++++++++++++++++++ testgen/generate_cmp_perf_tests.go | 40 +++------------------- testgen/generate_function_code_tests.go | 40 +++------------------- testgen/generate_validation_code_tests.go | 40 +++------------------- testgen/generate_validation_types_tests.go | 40 +++------------------- 5 files changed, 53 insertions(+), 144 deletions(-) create mode 100644 testgen/execute_template.go diff --git a/testgen/execute_template.go b/testgen/execute_template.go new file mode 100644 index 0000000..42716b1 --- /dev/null +++ b/testgen/execute_template.go @@ -0,0 +1,37 @@ +package main + +import ( + "bytes" + "fmt" + "go/format" + "os" + "text/template" +) + +func ExecTemplate(tplName, tplFile, output string, data any) error { + tpl, err := os.ReadFile(tplFile) + if err != nil { + return fmt.Errorf("error reading %s: %s", tplFile, err) + } + + tmpl, err := template.New(tplName).Parse(string(tpl)) + if err != nil { + return fmt.Errorf("error parsing template %s: %s", tplFile, err) + } + + code := new(bytes.Buffer) + if err := tmpl.Execute(code, data); err != nil { + return err + } + + formattedCode, err := format.Source(code.Bytes()) + if err != nil { + return err + } + + if err := os.WriteFile(output, formattedCode, 0644); err != nil { + return err + } + + return nil +} diff --git a/testgen/generate_cmp_perf_tests.go b/testgen/generate_cmp_perf_tests.go index c919c27..ee64ea5 100644 --- a/testgen/generate_cmp_perf_tests.go +++ b/testgen/generate_cmp_perf_tests.go @@ -1,12 +1,8 @@ package main import ( - "bytes" "fmt" - "go/format" - "os" "strings" - "text/template" "github.com/opencodeco/validgen/internal/common" "golang.org/x/text/cases" @@ -38,8 +34,8 @@ func generateComparativePerformanceTests() error { return nil } -func generateComparativePerformanceTest(tpl, dest string, pointer bool) error { - fmt.Printf("Generating comparative performance tests file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) +func generateComparativePerformanceTest(tplFile, outputFile string, pointer bool) error { + fmt.Printf("Generating comparative performance tests file: tplFile[%s] outputFile[%s] pointer[%v]\n", tplFile, outputFile, pointer) benchTests := CmpBenchTests{} @@ -94,39 +90,11 @@ func generateComparativePerformanceTest(tpl, dest string, pointer bool) error { fmt.Printf("%d test cases were generated\n", len(benchTests.Tests)) - if err := benchTests.GenerateFile(tpl, dest); err != nil { + if err := ExecTemplate("BenchTest", tplFile, outputFile, benchTests); err != nil { return fmt.Errorf("error generating comparative performance tests file %s", err) } - fmt.Println("Generating done") - - return nil -} - -func (cbt *CmpBenchTests) GenerateFile(tplFile, output string) error { - tpl, err := os.ReadFile(tplFile) - if err != nil { - return fmt.Errorf("error reading %s: %s", tplFile, err) - } - - tmpl, err := template.New("BenchTest").Parse(string(tpl)) - if err != nil { - return fmt.Errorf("error parsing template %s: %s", tplFile, err) - } - - code := new(bytes.Buffer) - if err := tmpl.Execute(code, cbt); err != nil { - return err - } - - formattedCode, err := format.Source(code.Bytes()) - if err != nil { - return err - } - - if err := os.WriteFile(output, formattedCode, 0644); err != nil { - return err - } + fmt.Printf("Generating %s done\n", outputFile) return nil } diff --git a/testgen/generate_function_code_tests.go b/testgen/generate_function_code_tests.go index 0b20f83..cf6b584 100644 --- a/testgen/generate_function_code_tests.go +++ b/testgen/generate_function_code_tests.go @@ -1,11 +1,7 @@ package main import ( - "bytes" "fmt" - "go/format" - "os" - "text/template" "github.com/opencodeco/validgen/internal/analyzer" "github.com/opencodeco/validgen/internal/codegenerator" @@ -45,8 +41,8 @@ func generateFunctionCodeUnitTests() error { return nil } -func generateFunctionCodeUnitTest(tpl, dest string, pointer bool) error { - fmt.Printf("Generating function code test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) +func generateFunctionCodeUnitTest(tplFile, outputFile string, pointer bool) error { + fmt.Printf("Generating function code test file: tplFile[%s] outputFile[%s] pointer[%v]\n", tplFile, outputFile, pointer) funcName := "TestBuildFunctionCode" if pointer { @@ -124,39 +120,11 @@ func generateFunctionCodeUnitTest(tpl, dest string, pointer bool) error { testCases.Tests = append(testCases.Tests, newTest) } - if err := testCases.GenerateFile(tpl, dest); err != nil { + if err := ExecTemplate("FunctionCodeTests", tplFile, outputFile, testCases); err != nil { return fmt.Errorf("generating function code tests file %s", err) } - fmt.Printf("Generating %s done\n", dest) - - return nil -} - -func (tc *FunctionCodeTestCases) GenerateFile(tplFile, output string) error { - tpl, err := os.ReadFile(tplFile) - if err != nil { - return fmt.Errorf("error reading %s: %s", tplFile, err) - } - - tmpl, err := template.New("ValidationCodeTests").Parse(string(tpl)) - if err != nil { - return err - } - - code := new(bytes.Buffer) - if err := tmpl.Execute(code, tc); err != nil { - return err - } - - formattedCode, err := format.Source(code.Bytes()) - if err != nil { - return err - } - - if err := os.WriteFile(output, formattedCode, 0644); err != nil { - return err - } + fmt.Printf("Generating %s done\n", outputFile) return nil } diff --git a/testgen/generate_validation_code_tests.go b/testgen/generate_validation_code_tests.go index f5ab371..5b02e4a 100644 --- a/testgen/generate_validation_code_tests.go +++ b/testgen/generate_validation_code_tests.go @@ -1,11 +1,7 @@ package main import ( - "bytes" "fmt" - "go/format" - "os" - "text/template" "github.com/opencodeco/validgen/internal/analyzer" "github.com/opencodeco/validgen/internal/codegenerator" @@ -39,8 +35,8 @@ func generateValidationCodeUnitTests() error { return nil } -func generateValidationCodeUnitTest(tpl, dest string, pointer bool) error { - fmt.Printf("Generating validation code test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) +func generateValidationCodeUnitTest(tplFile, outputFile string, pointer bool) error { + fmt.Printf("Generating validation code test file: tplFile[%s] outputFile[%s] pointer[%v]\n", tplFile, outputFile, pointer) funcName := "TestBuildValidationCode" if pointer { @@ -92,39 +88,11 @@ func generateValidationCodeUnitTest(tpl, dest string, pointer bool) error { } } - if err := testCases.GenerateFile(tpl, dest); err != nil { + if err := ExecTemplate("ValidationCodeTests", tplFile, outputFile, testCases); err != nil { return fmt.Errorf("error generating validation code tests file %s", err) } - fmt.Printf("Generating %s done\n", dest) - - return nil -} - -func (at *ValidationCodeTestCases) GenerateFile(tplFile, output string) error { - tpl, err := os.ReadFile(tplFile) - if err != nil { - return fmt.Errorf("error reading %s: %s", tplFile, err) - } - - tmpl, err := template.New("ValidationCodeTests").Parse(string(tpl)) - if err != nil { - return err - } - - code := new(bytes.Buffer) - if err := tmpl.Execute(code, at); err != nil { - return err - } - - formattedCode, err := format.Source(code.Bytes()) - if err != nil { - return err - } - - if err := os.WriteFile(output, formattedCode, 0644); err != nil { - return err - } + fmt.Printf("Generating %s done\n", outputFile) return nil } diff --git a/testgen/generate_validation_types_tests.go b/testgen/generate_validation_types_tests.go index 0bfa2f7..0b3ebd6 100644 --- a/testgen/generate_validation_types_tests.go +++ b/testgen/generate_validation_types_tests.go @@ -1,12 +1,8 @@ package main import ( - "bytes" "fmt" - "go/format" - "os" "strings" - "text/template" "github.com/opencodeco/validgen/internal/common" "golang.org/x/text/cases" @@ -44,8 +40,8 @@ func generateValidationTypesEndToEndTests() error { return nil } -func generateValidationTypesEndToEndTest(tpl, dest string, pointer bool) error { - fmt.Printf("Generating validation types test file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) +func generateValidationTypesEndToEndTest(tplFile, outputFile string, pointer bool) error { + fmt.Printf("Generating validation types test file: tplFile[%s] outputFile[%s] pointer[%v]\n", tplFile, outputFile, pointer) allTestsToGenerate := AllTestCasesToGenerate{} @@ -95,39 +91,11 @@ func generateValidationTypesEndToEndTest(tpl, dest string, pointer bool) error { } } - if err := allTestsToGenerate.GenerateFile(tpl, dest); err != nil { + if err := ExecTemplate("ValidationTypesTests", tplFile, outputFile, allTestsToGenerate); err != nil { return fmt.Errorf("generating validation types file %s", err) } - fmt.Printf("Generating %s done\n", dest) - - return nil -} - -func (tc *AllTestCasesToGenerate) GenerateFile(tplFile, output string) error { - tpl, err := os.ReadFile(tplFile) - if err != nil { - return fmt.Errorf("error reading %s: %s", tplFile, err) - } - - tmpl, err := template.New("ValidationTypesTests").Parse(string(tpl)) - if err != nil { - return err - } - - code := new(bytes.Buffer) - if err := tmpl.Execute(code, tc); err != nil { - return err - } - - formattedCode, err := format.Source(code.Bytes()) - if err != nil { - return err - } - - if err := os.WriteFile(output, formattedCode, 0644); err != nil { - return err - } + fmt.Printf("Generating %s done\n", outputFile) return nil } From 72a90ecc4ce134cb1183bafcd18fe46fe08dd3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20S=2E=20Garz=C3=A3o?= Date: Sun, 2 Nov 2025 11:44:58 -0300 Subject: [PATCH 22/31] chore: remove old way to generate cmp benchtests --- Makefile | 8 +- .../generate_cmp_benchtests_main.go | 134 --------- .../generated_cmp_perf_no_pointer_test.go | 0 .../generated_cmp_perf_pointer_test.go | 0 tests/cmpbenchtests/generated_tests/types.go | 83 ------ .../validgen_vs_validator_test.go | 279 ------------------ tests/cmpbenchtests/types.tpl | 12 - .../{generated_tests => }/validator__.go | 70 ----- .../validgen_vs_validator_test.tpl | 37 --- 9 files changed, 3 insertions(+), 620 deletions(-) delete mode 100644 tests/cmpbenchtests/generate_cmp_benchtests_main.go rename tests/cmpbenchtests/{generated_tests => }/generated_cmp_perf_no_pointer_test.go (100%) rename tests/cmpbenchtests/{generated_tests => }/generated_cmp_perf_pointer_test.go (100%) delete mode 100644 tests/cmpbenchtests/generated_tests/types.go delete mode 100644 tests/cmpbenchtests/generated_tests/validgen_vs_validator_test.go delete mode 100644 tests/cmpbenchtests/types.tpl rename tests/cmpbenchtests/{generated_tests => }/validator__.go (97%) delete mode 100644 tests/cmpbenchtests/validgen_vs_validator_test.tpl diff --git a/Makefile b/Makefile index 48b817d..4fd8827 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ build: clean testgen: @echo "Generating tests" - cd testgen/ && rm -f generated_*.go && go run *.go && mv generated_endtoend_*tests.go ../tests/endtoend/ && mv generated_validation_*_test.go ../internal/codegenerator/ && mv generated_function_code_*_test.go ../internal/codegenerator/ && mv generated_cmp_perf_*.go ../tests/cmpbenchtests/generated_tests/ + cd testgen/ && rm -f generated_*.go && go run *.go && mv generated_endtoend_*tests.go ../tests/endtoend/ && mv generated_validation_*_test.go ../internal/codegenerator/ && mv generated_function_code_*_test.go ../internal/codegenerator/ && mv generated_cmp_perf_*.go ../tests/cmpbenchtests/ endtoendtests: build @echo "Running endtoend tests" @@ -41,11 +41,9 @@ endtoendtests: build cmpbenchtests: build @echo "Running cmp bench tests" - rm -f tests/cmpbenchtests/generated_tests/valid*.go && rm -f tests/cmpbenchtests/generated_tests/types.go - cd tests/cmpbenchtests; go run . - $(VALIDGEN_BIN) tests/cmpbenchtests/generated_tests + $(VALIDGEN_BIN) tests/cmpbenchtests/ go clean -testcache - go test -bench=. -v -benchmem -benchtime=$(BENCH_TIME) ./tests/cmpbenchtests/generated_tests + go test -bench=. -v -benchmem -benchtime=$(BENCH_TIME) ./tests/cmpbenchtests/ setup: @echo "Setting up" diff --git a/tests/cmpbenchtests/generate_cmp_benchtests_main.go b/tests/cmpbenchtests/generate_cmp_benchtests_main.go deleted file mode 100644 index f84b914..0000000 --- a/tests/cmpbenchtests/generate_cmp_benchtests_main.go +++ /dev/null @@ -1,134 +0,0 @@ -package main - -import ( - "bytes" - "fmt" - "log" - "os" - "text/template" -) - -type BenchTests struct { - Tests []Test -} - -type Test struct { - TestType string - FieldType string - ValidGenValidate string - ValidatorValidate string - ValidInput string -} - -func main() { - log.Println("Generating benchtest files") - - benchTests := BenchTests{} - benchTests.Tests = []Test{ - { - TestType: "StringRequired", - FieldType: "string", - ValidGenValidate: "required", - ValidatorValidate: "required", - ValidInput: "xpto", - }, - { - TestType: "StringEq", - FieldType: "string", - ValidGenValidate: "eq=abc", - ValidatorValidate: "eq=abc", - ValidInput: "abc", - }, - { - TestType: "StringEqIC", - FieldType: "string", - ValidGenValidate: "eq_ignore_case=abc", - ValidatorValidate: "eq_ignore_case=abc", - ValidInput: "AbC", - }, - { - TestType: "StringNeq", - FieldType: "string", - ValidGenValidate: "neq=abc", - ValidatorValidate: "ne=abc", - ValidInput: "123", - }, - { - TestType: "StringNeqIC", - FieldType: "string", - ValidGenValidate: "neq_ignore_case=abc", - ValidatorValidate: "ne_ignore_case=abc", - ValidInput: "123", - }, - { - TestType: "StringLen", - FieldType: "string", - ValidGenValidate: "len=5", - ValidatorValidate: "len=5", - ValidInput: "abcde", - }, - { - TestType: "StringMax", - FieldType: "string", - ValidGenValidate: "max=5", - ValidatorValidate: "max=5", - ValidInput: "abcde", - }, - { - TestType: "StringMin", - FieldType: "string", - ValidGenValidate: "min=3", - ValidatorValidate: "min=3", - ValidInput: "abcd", - }, - { - TestType: "StringIn", - FieldType: "string", - ValidGenValidate: "in=ab cd ef", - ValidatorValidate: "oneof=ab cd ef", - ValidInput: "ef", - }, - { - TestType: "StringEmail", - FieldType: "string", - ValidGenValidate: "email", - ValidatorValidate: "email", - ValidInput: "aaa@example.com", - }, - - // nin - } - - if err := benchTests.GenerateFile("types.tpl", "./generated_tests/types.go"); err != nil { - log.Fatalf("error generation types file %s", err) - } - - if err := benchTests.GenerateFile("validgen_vs_validator_test.tpl", "./generated_tests/validgen_vs_validator_test.go"); err != nil { - log.Fatalf("error generation test file %s", err) - } - - log.Println("Generating done") -} - -func (bt *BenchTests) GenerateFile(tplFile, output string) error { - tpl, err := os.ReadFile(tplFile) - if err != nil { - return fmt.Errorf("error reading %s: %s", tplFile, err) - } - - tmpl, err := template.New("BenchTest").Parse(string(tpl)) - if err != nil { - return fmt.Errorf("error parsing template %s: %s", tplFile, err) - } - - code := new(bytes.Buffer) - if err := tmpl.Execute(code, bt); err != nil { - return err - } - - if err := os.WriteFile(output, code.Bytes(), 0644); err != nil { - return err - } - - return nil -} diff --git a/tests/cmpbenchtests/generated_tests/generated_cmp_perf_no_pointer_test.go b/tests/cmpbenchtests/generated_cmp_perf_no_pointer_test.go similarity index 100% rename from tests/cmpbenchtests/generated_tests/generated_cmp_perf_no_pointer_test.go rename to tests/cmpbenchtests/generated_cmp_perf_no_pointer_test.go diff --git a/tests/cmpbenchtests/generated_tests/generated_cmp_perf_pointer_test.go b/tests/cmpbenchtests/generated_cmp_perf_pointer_test.go similarity index 100% rename from tests/cmpbenchtests/generated_tests/generated_cmp_perf_pointer_test.go rename to tests/cmpbenchtests/generated_cmp_perf_pointer_test.go diff --git a/tests/cmpbenchtests/generated_tests/types.go b/tests/cmpbenchtests/generated_tests/types.go deleted file mode 100644 index 27871d7..0000000 --- a/tests/cmpbenchtests/generated_tests/types.go +++ /dev/null @@ -1,83 +0,0 @@ -// Code generated by BenchTestGenerator. DO NOT EDIT. - -package benchtests - -type ValidGenStringRequiredStruct struct { - Field string `valid:"required"` -} - -type ValidatorStringRequiredStruct struct { - Field string `validate:"required"` -} - -type ValidGenStringEqStruct struct { - Field string `valid:"eq=abc"` -} - -type ValidatorStringEqStruct struct { - Field string `validate:"eq=abc"` -} - -type ValidGenStringEqICStruct struct { - Field string `valid:"eq_ignore_case=abc"` -} - -type ValidatorStringEqICStruct struct { - Field string `validate:"eq_ignore_case=abc"` -} - -type ValidGenStringNeqStruct struct { - Field string `valid:"neq=abc"` -} - -type ValidatorStringNeqStruct struct { - Field string `validate:"ne=abc"` -} - -type ValidGenStringNeqICStruct struct { - Field string `valid:"neq_ignore_case=abc"` -} - -type ValidatorStringNeqICStruct struct { - Field string `validate:"ne_ignore_case=abc"` -} - -type ValidGenStringLenStruct struct { - Field string `valid:"len=5"` -} - -type ValidatorStringLenStruct struct { - Field string `validate:"len=5"` -} - -type ValidGenStringMaxStruct struct { - Field string `valid:"max=5"` -} - -type ValidatorStringMaxStruct struct { - Field string `validate:"max=5"` -} - -type ValidGenStringMinStruct struct { - Field string `valid:"min=3"` -} - -type ValidatorStringMinStruct struct { - Field string `validate:"min=3"` -} - -type ValidGenStringInStruct struct { - Field string `valid:"in=ab cd ef"` -} - -type ValidatorStringInStruct struct { - Field string `validate:"oneof=ab cd ef"` -} - -type ValidGenStringEmailStruct struct { - Field string `valid:"email"` -} - -type ValidatorStringEmailStruct struct { - Field string `validate:"email"` -} diff --git a/tests/cmpbenchtests/generated_tests/validgen_vs_validator_test.go b/tests/cmpbenchtests/generated_tests/validgen_vs_validator_test.go deleted file mode 100644 index 52a3c9d..0000000 --- a/tests/cmpbenchtests/generated_tests/validgen_vs_validator_test.go +++ /dev/null @@ -1,279 +0,0 @@ -// Code generated by BenchTestGenerator. DO NOT EDIT. - -package benchtests - -import ( - "testing" - - "github.com/go-playground/validator/v10" -) - -func BenchmarkValidGenStringRequired(b *testing.B) { - data := &ValidGenStringRequiredStruct{ - Field: "xpto", - } - - for b.Loop() { - if err := ValidGenStringRequiredStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringRequired(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringRequiredStruct{ - Field: "xpto", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} - -func BenchmarkValidGenStringEq(b *testing.B) { - data := &ValidGenStringEqStruct{ - Field: "abc", - } - - for b.Loop() { - if err := ValidGenStringEqStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringEq(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringEqStruct{ - Field: "abc", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} - -func BenchmarkValidGenStringEqIC(b *testing.B) { - data := &ValidGenStringEqICStruct{ - Field: "AbC", - } - - for b.Loop() { - if err := ValidGenStringEqICStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringEqIC(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringEqICStruct{ - Field: "AbC", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} - -func BenchmarkValidGenStringNeq(b *testing.B) { - data := &ValidGenStringNeqStruct{ - Field: "123", - } - - for b.Loop() { - if err := ValidGenStringNeqStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringNeq(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringNeqStruct{ - Field: "123", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} - -func BenchmarkValidGenStringNeqIC(b *testing.B) { - data := &ValidGenStringNeqICStruct{ - Field: "123", - } - - for b.Loop() { - if err := ValidGenStringNeqICStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringNeqIC(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringNeqICStruct{ - Field: "123", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} - -func BenchmarkValidGenStringLen(b *testing.B) { - data := &ValidGenStringLenStruct{ - Field: "abcde", - } - - for b.Loop() { - if err := ValidGenStringLenStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringLen(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringLenStruct{ - Field: "abcde", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} - -func BenchmarkValidGenStringMax(b *testing.B) { - data := &ValidGenStringMaxStruct{ - Field: "abcde", - } - - for b.Loop() { - if err := ValidGenStringMaxStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringMax(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringMaxStruct{ - Field: "abcde", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} - -func BenchmarkValidGenStringMin(b *testing.B) { - data := &ValidGenStringMinStruct{ - Field: "abcd", - } - - for b.Loop() { - if err := ValidGenStringMinStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringMin(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringMinStruct{ - Field: "abcd", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} - -func BenchmarkValidGenStringIn(b *testing.B) { - data := &ValidGenStringInStruct{ - Field: "ef", - } - - for b.Loop() { - if err := ValidGenStringInStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringIn(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringInStruct{ - Field: "ef", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} - -func BenchmarkValidGenStringEmail(b *testing.B) { - data := &ValidGenStringEmailStruct{ - Field: "aaa@example.com", - } - - for b.Loop() { - if err := ValidGenStringEmailStructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidatorStringEmail(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &ValidatorStringEmailStruct{ - Field: "aaa@example.com", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} diff --git a/tests/cmpbenchtests/types.tpl b/tests/cmpbenchtests/types.tpl deleted file mode 100644 index de97fc9..0000000 --- a/tests/cmpbenchtests/types.tpl +++ /dev/null @@ -1,12 +0,0 @@ -// Code generated by BenchTestGenerator. DO NOT EDIT. - -package benchtests -{{range .Tests}} -type ValidGen{{.TestType}}Struct struct { - Field {{.FieldType}} `valid:"{{.ValidGenValidate}}"` -} - -type Validator{{.TestType}}Struct struct { - Field {{.FieldType}} `validate:"{{.ValidatorValidate}}"` -} -{{end}} \ No newline at end of file diff --git a/tests/cmpbenchtests/generated_tests/validator__.go b/tests/cmpbenchtests/validator__.go similarity index 97% rename from tests/cmpbenchtests/generated_tests/validator__.go rename to tests/cmpbenchtests/validator__.go index 5684e0a..0a8fffb 100755 --- a/tests/cmpbenchtests/generated_tests/validator__.go +++ b/tests/cmpbenchtests/validator__.go @@ -3170,73 +3170,3 @@ func ValidGenRequiredUintStructValidate(obj *ValidGenRequiredUintStruct) []error } return errs } -func ValidGenStringEmailStructValidate(obj *ValidGenStringEmailStruct) []error { - var errs []error - if !(types.IsValidEmail(obj.Field)) { - errs = append(errs, types.NewValidationError("Field must be a valid email")) - } - return errs -} -func ValidGenStringEqICStructValidate(obj *ValidGenStringEqICStruct) []error { - var errs []error - if !(types.EqualFold(obj.Field, "abc")) { - errs = append(errs, types.NewValidationError("Field must be equal to 'abc'")) - } - return errs -} -func ValidGenStringEqStructValidate(obj *ValidGenStringEqStruct) []error { - var errs []error - if !(obj.Field == "abc") { - errs = append(errs, types.NewValidationError("Field must be equal to 'abc'")) - } - return errs -} -func ValidGenStringInStructValidate(obj *ValidGenStringInStruct) []error { - var errs []error - if !(obj.Field == "ab" || obj.Field == "cd" || obj.Field == "ef") { - errs = append(errs, types.NewValidationError("Field must be one of 'ab' 'cd' 'ef'")) - } - return errs -} -func ValidGenStringLenStructValidate(obj *ValidGenStringLenStruct) []error { - var errs []error - if !(len(obj.Field) == 5) { - errs = append(errs, types.NewValidationError("Field length must be 5")) - } - return errs -} -func ValidGenStringMaxStructValidate(obj *ValidGenStringMaxStruct) []error { - var errs []error - if !(len(obj.Field) <= 5) { - errs = append(errs, types.NewValidationError("Field length must be <= 5")) - } - return errs -} -func ValidGenStringMinStructValidate(obj *ValidGenStringMinStruct) []error { - var errs []error - if !(len(obj.Field) >= 3) { - errs = append(errs, types.NewValidationError("Field length must be >= 3")) - } - return errs -} -func ValidGenStringNeqICStructValidate(obj *ValidGenStringNeqICStruct) []error { - var errs []error - if !(!types.EqualFold(obj.Field, "abc")) { - errs = append(errs, types.NewValidationError("Field must not be equal to 'abc'")) - } - return errs -} -func ValidGenStringNeqStructValidate(obj *ValidGenStringNeqStruct) []error { - var errs []error - if !(obj.Field != "abc") { - errs = append(errs, types.NewValidationError("Field must not be equal to 'abc'")) - } - return errs -} -func ValidGenStringRequiredStructValidate(obj *ValidGenStringRequiredStruct) []error { - var errs []error - if !(obj.Field != "") { - errs = append(errs, types.NewValidationError("Field is required")) - } - return errs -} diff --git a/tests/cmpbenchtests/validgen_vs_validator_test.tpl b/tests/cmpbenchtests/validgen_vs_validator_test.tpl deleted file mode 100644 index 472e253..0000000 --- a/tests/cmpbenchtests/validgen_vs_validator_test.tpl +++ /dev/null @@ -1,37 +0,0 @@ -// Code generated by BenchTestGenerator. DO NOT EDIT. - -package benchtests - -import ( - "testing" - - "github.com/go-playground/validator/v10" -) -{{range .Tests}} -func BenchmarkValidGen{{.TestType}}(b *testing.B) { - data := &ValidGen{{.TestType}}Struct{ - Field: "{{.ValidInput}}", - } - - for b.Loop() { - if err := ValidGen{{.TestType}}StructValidate(data); len(err) > 0 { - b.FailNow() - } - } -} - -func BenchmarkValidator{{.TestType}}(b *testing.B) { - var validate *validator.Validate - - validate = validator.New(validator.WithRequiredStructEnabled()) - data := &Validator{{.TestType}}Struct{ - Field: "{{.ValidInput}}", - } - - for b.Loop() { - if err := validate.Struct(data); err != nil { - b.FailNow() - } - } -} -{{end}} \ No newline at end of file From f6527529138120d8310a54da5ff8485c0bebf0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Sandro=20Garz=C3=A3o?= Date: Tue, 4 Nov 2025 19:30:22 -0300 Subject: [PATCH 23/31] chore: add missed \n in error messages --- testgen/generate_tests.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testgen/generate_tests.go b/testgen/generate_tests.go index ea41aaf..de0144f 100644 --- a/testgen/generate_tests.go +++ b/testgen/generate_tests.go @@ -9,22 +9,22 @@ func main() { fmt.Println("Generating tests files") if err := generateValidationTypesEndToEndTests(); err != nil { - fmt.Printf("error generating validation types end-to-end tests: %s", err) + fmt.Printf("error generating validation types end-to-end tests: %s\n", err) os.Exit(1) } if err := generateValidationCodeUnitTests(); err != nil { - fmt.Printf("error generating validation code unit tests: %s", err) + fmt.Printf("error generating validation code unit tests: %s\n", err) os.Exit(1) } if err := generateFunctionCodeUnitTests(); err != nil { - fmt.Printf("error generating function code unit tests: %s", err) + fmt.Printf("error generating function code unit tests: %s\n", err) os.Exit(1) } if err := generateComparativePerformanceTests(); err != nil { - fmt.Printf("error generating comparative performance tests: %s", err) + fmt.Printf("error generating comparative performance tests: %s\n", err) os.Exit(1) } From 10fbd60fe8ac7cea25ecd8263574bf51ecabc809 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Sandro=20Garz=C3=A3o?= Date: Fri, 7 Nov 2025 19:19:53 -0300 Subject: [PATCH 24/31] chore: remove tests generated by testgen --- .../codegenerator/build_validator_test.go | 394 +----------------- 1 file changed, 1 insertion(+), 393 deletions(-) diff --git a/internal/codegenerator/build_validator_test.go b/internal/codegenerator/build_validator_test.go index ae53669..1cda4a0 100644 --- a/internal/codegenerator/build_validator_test.go +++ b/internal/codegenerator/build_validator_test.go @@ -1,7 +1,6 @@ package codegenerator import ( - "fmt" "testing" "github.com/opencodeco/validgen/internal/analyzer" @@ -9,7 +8,7 @@ import ( "github.com/opencodeco/validgen/internal/parser" ) -func TestBuildValidationCodeOld(t *testing.T) { +func TestBuildValidationCodeFieldOperations(t *testing.T) { type args struct { fieldName string fieldType common.FieldType @@ -20,152 +19,6 @@ func TestBuildValidationCodeOld(t *testing.T) { args args want string }{ - { - name: "if code with string", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string"}, - fieldValidation: "eq=abc", - }, - want: `if !(obj.strField == "abc") { -errs = append(errs, types.NewValidationError("strField must be equal to 'abc'")) -} -`, - }, - { - name: "if code with uint8", - args: args{ - fieldName: "intField", - fieldType: common.FieldType{BaseType: "uint8"}, - fieldValidation: "gte=123", - }, - want: `if !(obj.intField >= 123) { -errs = append(errs, types.NewValidationError("intField must be >= 123")) -} -`, - }, - { - name: "if code with string and in", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string"}, - fieldValidation: "in=a b c", - }, - want: `if !(obj.strField == "a" || obj.strField == "b" || obj.strField == "c") { -errs = append(errs, types.NewValidationError("strField must be one of 'a' 'b' 'c'")) -} -`, - }, - { - name: "if code with string and not in", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string"}, - fieldValidation: "nin=a b c", - }, - want: `if !(obj.strField != "a" && obj.strField != "b" && obj.strField != "c") { -errs = append(errs, types.NewValidationError("strField must not be one of 'a' 'b' 'c'")) -} -`, - }, - { - name: "Required slice string", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[]"}, - fieldValidation: "required", - }, - want: `if !(len(obj.strField) != 0) { -errs = append(errs, types.NewValidationError("strField must not be empty")) -} -`, - }, - { - name: "Min slice string", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[]"}, - fieldValidation: "min=2", - }, - want: `if !(len(obj.strField) >= 2) { -errs = append(errs, types.NewValidationError("strField must have at least 2 elements")) -} -`, - }, - { - name: "Max slice string", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[]"}, - fieldValidation: "max=5", - }, - want: `if !(len(obj.strField) <= 5) { -errs = append(errs, types.NewValidationError("strField must have at most 5 elements")) -} -`, - }, - { - name: "Len slice string", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[]"}, - fieldValidation: "len=3", - }, - want: `if !(len(obj.strField) == 3) { -errs = append(errs, types.NewValidationError("strField must have exactly 3 elements")) -} -`, - }, - { - name: "In slice string", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[]"}, - fieldValidation: "in=a b c", - }, - want: `if !(types.SliceOnlyContains(obj.strField, []string{"a", "b", "c"})) { -errs = append(errs, types.NewValidationError("strField elements must be one of 'a' 'b' 'c'")) -} -`, - }, - { - name: "Not in slice string", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[]"}, - fieldValidation: "nin=a b c", - }, - want: `if !(types.SliceNotContains(obj.strField, []string{"a", "b", "c"})) { -errs = append(errs, types.NewValidationError("strField elements must not be one of 'a' 'b' 'c'")) -} -`, - }, - - { - name: "In array string", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[N]"}, - fieldValidation: "in=a b c", - }, - want: `if !(types.SliceOnlyContains(obj.strField[:], []string{"a", "b", "c"})) { -errs = append(errs, types.NewValidationError("strField elements must be one of 'a' 'b' 'c'")) -} -`, - }, - { - name: "Not in array string", - args: args{ - fieldName: "strField", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[N]"}, - fieldValidation: "nin=a b c", - }, - want: `if !(types.SliceNotContains(obj.strField[:], []string{"a", "b", "c"})) { -errs = append(errs, types.NewValidationError("strField elements must not be one of 'a' 'b' 'c'")) -} -`, - }, - { name: "inner field operation", args: args{ @@ -188,71 +41,6 @@ errs = append(errs, types.NewValidationError("field1 must be equal to field2")) want: `if !(obj.field1 == obj.Nested.field2) { errs = append(errs, types.NewValidationError("field1 must be equal to Nested.field2")) } -`, - }, - - { - name: "if code with bool", - args: args{ - fieldName: "boolField", - fieldType: common.FieldType{BaseType: "bool"}, - fieldValidation: "eq=true", - }, - want: `if !(obj.boolField == true) { -errs = append(errs, types.NewValidationError("boolField must be equal to true")) -} -`, - }, - - { - name: "if code with int", - args: args{ - fieldName: "intField", - fieldType: common.FieldType{BaseType: "int"}, - fieldValidation: "eq=5", - }, - want: `if !(obj.intField == 5) { -errs = append(errs, types.NewValidationError("intField must be equal to 5")) -} -`, - }, - - { - name: "if code with float32", - args: args{ - fieldName: "floatField", - fieldType: common.FieldType{BaseType: "float32"}, - fieldValidation: "eq=5.0", - }, - want: `if !(obj.floatField == 5.0) { -errs = append(errs, types.NewValidationError("floatField must be equal to 5.0")) -} -`, - }, - - // Map type - { - name: "if code with string map", - args: args{ - fieldName: "mapField", - fieldType: common.FieldType{BaseType: "string", ComposedType: "map"}, - fieldValidation: "len=3", - }, - want: `if !(len(obj.mapField) == 3) { -errs = append(errs, types.NewValidationError("mapField must have exactly 3 elements")) -} -`, - }, - { - name: "if code with uint8 map", - args: args{ - fieldName: "mapField", - fieldType: common.FieldType{BaseType: "uint8", ComposedType: "map"}, - fieldValidation: "len=3", - }, - want: `if !(len(obj.mapField) == 3) { -errs = append(errs, types.NewValidationError("mapField must have exactly 3 elements")) -} `, }, } @@ -312,18 +100,6 @@ func TestBuildValidationCodeWithNestedStructsAndSlices(t *testing.T) { want: `if !(len(obj.Field) != 0) { errs = append(errs, types.NewValidationError("Field must not be empty")) } -`, - }, - { - name: "test code with min slice of string", - args: args{ - fieldName: "Field", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[]"}, - fieldValidation: "min=2", - }, - want: `if !(len(obj.Field) >= 2) { -errs = append(errs, types.NewValidationError("Field must have at least 2 elements")) -} `, }, } @@ -351,171 +127,3 @@ errs = append(errs, types.NewValidationError("Field must have at least 2 element }) } } - -func TestBuildValidationCodeWithPointerTypes(t *testing.T) { - tests := []struct { - fieldType common.FieldType - validation string - want string - }{ - // Pointer basic types. - { - fieldType: common.FieldType{BaseType: "string", ComposedType: "*"}, - validation: "eq=abc", - want: `if !(obj.field != nil && *obj.field == "abc") { -errs = append(errs, types.NewValidationError("field must be equal to 'abc'")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "bool", ComposedType: "*"}, - validation: "eq=true", - want: `if !(obj.field != nil && *obj.field == true) { -errs = append(errs, types.NewValidationError("field must be equal to true")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "int", ComposedType: "*"}, - validation: "eq=5", - want: `if !(obj.field != nil && *obj.field == 5) { -errs = append(errs, types.NewValidationError("field must be equal to 5")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "float32", ComposedType: "*"}, - validation: "eq=5.0", - want: `if !(obj.field != nil && *obj.field == 5.0) { -errs = append(errs, types.NewValidationError("field must be equal to 5.0")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "bool", ComposedType: "*"}, - validation: "eq=true", - want: `if !(obj.field != nil && *obj.field == true) { -errs = append(errs, types.NewValidationError("field must be equal to true")) -} -`, - }, - - // Slice pointer types. - { - fieldType: common.FieldType{BaseType: "string", ComposedType: "*[]"}, - validation: "required", - want: `if !(obj.field != nil && len(*obj.field) != 0) { -errs = append(errs, types.NewValidationError("field must not be empty")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "int", ComposedType: "*[]"}, - validation: "min=10", - want: `if !(obj.field != nil && len(*obj.field) >= 10) { -errs = append(errs, types.NewValidationError("field must have at least 10 elements")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "float32", ComposedType: "*[]"}, - validation: "in=10.0 12.0 14.0", - want: `if !(obj.field != nil && types.SliceOnlyContains(*obj.field, []float32{10.0, 12.0, 14.0})) { -errs = append(errs, types.NewValidationError("field elements must be one of '10.0' '12.0' '14.0'")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "bool", ComposedType: "*[]"}, - validation: "min=3", - want: `if !(obj.field != nil && len(*obj.field) >= 3) { -errs = append(errs, types.NewValidationError("field must have at least 3 elements")) -} -`, - }, - - // Array pointer types. - { - fieldType: common.FieldType{BaseType: "string", ComposedType: "*[N]"}, - validation: "in=a b c", - want: `if !(obj.field != nil && types.SliceOnlyContains(obj.field[:], []string{"a", "b", "c"})) { -errs = append(errs, types.NewValidationError("field elements must be one of 'a' 'b' 'c'")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "int", ComposedType: "*[N]"}, - validation: "in=1 2 3", - want: `if !(obj.field != nil && types.SliceOnlyContains(obj.field[:], []int{1, 2, 3})) { -errs = append(errs, types.NewValidationError("field elements must be one of '1' '2' '3'")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "float32", ComposedType: "*[N]"}, - validation: "in=1.1 2.2 3.3", - want: `if !(obj.field != nil && types.SliceOnlyContains(obj.field[:], []float32{1.1, 2.2, 3.3})) { -errs = append(errs, types.NewValidationError("field elements must be one of '1.1' '2.2' '3.3'")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "bool", ComposedType: "*[N]"}, - validation: "in=true", - want: `if !(obj.field != nil && types.SliceOnlyContains(obj.field[:], []bool{true})) { -errs = append(errs, types.NewValidationError("field elements must be one of 'true'")) -} -`, - }, - - // Map pointer types. - { - fieldType: common.FieldType{BaseType: "string", ComposedType: "*map"}, - validation: "len=3", - want: `if !(obj.field != nil && len(*obj.field) == 3) { -errs = append(errs, types.NewValidationError("field must have exactly 3 elements")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "int", ComposedType: "*map"}, - validation: "len=3", - want: `if !(obj.field != nil && len(*obj.field) == 3) { -errs = append(errs, types.NewValidationError("field must have exactly 3 elements")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "float32", ComposedType: "*map"}, - validation: "len=3", - want: `if !(obj.field != nil && len(*obj.field) == 3) { -errs = append(errs, types.NewValidationError("field must have exactly 3 elements")) -} -`, - }, - { - fieldType: common.FieldType{BaseType: "bool", ComposedType: "*map"}, - validation: "len=3", - want: `if !(obj.field != nil && len(*obj.field) == 3) { -errs = append(errs, types.NewValidationError("field must have exactly 3 elements")) -} -`, - }, - } - - for _, tt := range tests { - testName := fmt.Sprintf("validation: %s with %s (%s)", tt.validation, tt.fieldType.ToGenericType(), tt.fieldType.ToNormalizedString()) - t.Run(testName, func(t *testing.T) { - gv := GenValidations{} - validation := AssertParserValidation(t, tt.validation) - got, err := gv.BuildValidationCode("field", tt.fieldType, []*analyzer.Validation{validation}) - if err != nil { - t.Errorf("BuildValidationCode() error = %v, wantErr %v", err, nil) - return - } - if got != tt.want { - t.Errorf("BuildValidationCode() = %v, want %v", got, tt.want) - } - }) - } -} From cb5a2bcf0420085449097a5d7e9cfad4278ed275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Sandro=20Garz=C3=A3o?= Date: Fri, 7 Nov 2025 19:58:35 -0300 Subject: [PATCH 25/31] chore: remove duplicated slice test --- internal/codegenerator/build_validator_test.go | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/internal/codegenerator/build_validator_test.go b/internal/codegenerator/build_validator_test.go index 1cda4a0..24694e8 100644 --- a/internal/codegenerator/build_validator_test.go +++ b/internal/codegenerator/build_validator_test.go @@ -61,7 +61,7 @@ errs = append(errs, types.NewValidationError("field1 must be equal to Nested.fie } } -func TestBuildValidationCodeWithNestedStructsAndSlices(t *testing.T) { +func TestBuildValidationCodeWithNestedStructs(t *testing.T) { type args struct { fieldName string fieldType common.FieldType @@ -90,18 +90,6 @@ func TestBuildValidationCodeWithNestedStructsAndSlices(t *testing.T) { }, want: "errs = append(errs, mypkg.InnerStructTypeValidate(&obj.Field)...)\n", }, - { - name: "test code with required slice of string", - args: args{ - fieldName: "Field", - fieldType: common.FieldType{BaseType: "string", ComposedType: "[]"}, - fieldValidation: "required", - }, - want: `if !(len(obj.Field) != 0) { -errs = append(errs, types.NewValidationError("Field must not be empty")) -} -`, - }, } for _, tt := range tests { From 5ab302c569a765b375d9a370324526b72486f622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Sandro=20Garz=C3=A3o?= Date: Fri, 7 Nov 2025 20:22:31 -0300 Subject: [PATCH 26/31] chore: remove duplicated tests --- .../build_func_validator_test.go | 75 +------------------ 1 file changed, 1 insertion(+), 74 deletions(-) diff --git a/internal/codegenerator/build_func_validator_test.go b/internal/codegenerator/build_func_validator_test.go index 6108d9a..27f9048 100644 --- a/internal/codegenerator/build_func_validator_test.go +++ b/internal/codegenerator/build_func_validator_test.go @@ -9,7 +9,7 @@ import ( "github.com/sergi/go-diff/diffmatchpatch" ) -func TestBuildFuncValidatorCode(t *testing.T) { +func TestBuildFuncValidatorCodeFieldOperations(t *testing.T) { type fields struct { Struct *analyzer.Struct } @@ -18,79 +18,6 @@ func TestBuildFuncValidatorCode(t *testing.T) { fields fields want string }{ - { - name: "Valid struct", - fields: fields{ - Struct: &analyzer.Struct{ - Struct: parser.Struct{ - PackageName: "main", - StructName: "User", - Fields: []parser.Field{ - { - FieldName: "FirstName", - Type: common.FieldType{BaseType: "string"}, - Tag: `validate:"required"`, - }, - { - FieldName: "MyAge", - Type: common.FieldType{BaseType: "uint8"}, - Tag: `validate:"required"`, - }, - }, - }, - FieldsValidations: []analyzer.FieldValidations{ - { - Validations: []*analyzer.Validation{AssertParserValidation(t, "required")}, - }, - { - Validations: []*analyzer.Validation{AssertParserValidation(t, "required")}, - }, - }, - }, - }, - want: `func UserValidate(obj *User) []error { -var errs []error -if !(obj.FirstName != "") { -errs = append(errs, types.NewValidationError("FirstName is required")) -} -if !(obj.MyAge != 0) { -errs = append(errs, types.NewValidationError("MyAge is required")) -} -return errs -} -`, - }, - { - name: "FirstName must have 5 characters or more", - fields: fields{ - Struct: &analyzer.Struct{ - Struct: parser.Struct{ - PackageName: "main", - StructName: "User", - Fields: []parser.Field{ - { - FieldName: "FirstName", - Type: common.FieldType{BaseType: "string"}, - Tag: `validate:"min=5"`, - }, - }, - }, - FieldsValidations: []analyzer.FieldValidations{ - { - Validations: []*analyzer.Validation{AssertParserValidation(t, "min=5")}, - }, - }, - }, - }, - want: `func UserValidate(obj *User) []error { -var errs []error -if !(len(obj.FirstName) >= 5) { -errs = append(errs, types.NewValidationError("FirstName length must be >= 5")) -} -return errs -} -`, - }, { name: "Field inner op", fields: fields{ From 9f4d82873e17ef697b937fb09f3b71fdb44af04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Sandro=20Garz=C3=A3o?= Date: Fri, 7 Nov 2025 20:28:43 -0300 Subject: [PATCH 27/31] chore: remove old end-to-end test generator --- .../generate_tests/generate_numeric_tests.go | 64 -- .../endtoend/generate_tests/generate_tests.go | 14 - .../generate_tests/generate_usecase_tests.go | 947 ------------------ .../generate_tests/no_pointer_tests.tpl | 50 - .../endtoend/generate_tests/numeric_float.tpl | 81 -- tests/endtoend/generate_tests/numeric_int.tpl | 81 -- .../endtoend/generate_tests/pointer_tests.tpl | 58 -- 7 files changed, 1295 deletions(-) delete mode 100644 tests/endtoend/generate_tests/generate_numeric_tests.go delete mode 100644 tests/endtoend/generate_tests/generate_tests.go delete mode 100644 tests/endtoend/generate_tests/generate_usecase_tests.go delete mode 100644 tests/endtoend/generate_tests/no_pointer_tests.tpl delete mode 100644 tests/endtoend/generate_tests/numeric_float.tpl delete mode 100644 tests/endtoend/generate_tests/numeric_int.tpl delete mode 100644 tests/endtoend/generate_tests/pointer_tests.tpl diff --git a/tests/endtoend/generate_tests/generate_numeric_tests.go b/tests/endtoend/generate_tests/generate_numeric_tests.go deleted file mode 100644 index 6c10b1c..0000000 --- a/tests/endtoend/generate_tests/generate_numeric_tests.go +++ /dev/null @@ -1,64 +0,0 @@ -package main - -import ( - "bytes" - "fmt" - "log" - "os" - "text/template" - - "github.com/opencodeco/validgen/internal/common" - "golang.org/x/text/cases" - "golang.org/x/text/language" -) - -type NumericTests struct { - FieldTypes []string -} - -func generateNumericTests() { - log.Println("Generating numeric test files") - - numericTests := NumericTests{} - numericTests.FieldTypes = common.HelperFromNormalizedToBasicTypes("") - - if err := numericTests.GenerateFile("numeric_int.tpl", "./generated_numeric_int_tests.go"); err != nil { - log.Fatalf("error generating numeric int file %s", err) - } - - numericTests = NumericTests{} - numericTests.FieldTypes = common.HelperFromNormalizedToBasicTypes("") - - if err := numericTests.GenerateFile("numeric_float.tpl", "./generated_numeric_float_tests.go"); err != nil { - log.Fatalf("error generating numeric float file %s", err) - } - - log.Println("Generating done") -} - -func (bt *NumericTests) GenerateFile(tplFile, output string) error { - tpl, err := os.ReadFile(tplFile) - if err != nil { - return fmt.Errorf("error reading %s: %s", tplFile, err) - } - - funcMap := template.FuncMap{ - "title": cases.Title(language.Und).String, - } - - tmpl, err := template.New("NumericTest").Funcs(funcMap).Parse(string(tpl)) - if err != nil { - return err - } - - code := new(bytes.Buffer) - if err := tmpl.Execute(code, bt); err != nil { - return err - } - - if err := os.WriteFile(output, code.Bytes(), 0644); err != nil { - return err - } - - return nil -} diff --git a/tests/endtoend/generate_tests/generate_tests.go b/tests/endtoend/generate_tests/generate_tests.go deleted file mode 100644 index da1d2c0..0000000 --- a/tests/endtoend/generate_tests/generate_tests.go +++ /dev/null @@ -1,14 +0,0 @@ -package main - -import ( - "log" -) - -func main() { - log.Println("Generating tests files") - - generateNumericTests() - generateTestCases() - - log.Println("Generating done") -} diff --git a/tests/endtoend/generate_tests/generate_usecase_tests.go b/tests/endtoend/generate_tests/generate_usecase_tests.go deleted file mode 100644 index 16a63e2..0000000 --- a/tests/endtoend/generate_tests/generate_usecase_tests.go +++ /dev/null @@ -1,947 +0,0 @@ -package main - -import ( - "bytes" - "fmt" - "go/format" - "log" - "os" - "strings" - "text/template" - - "github.com/opencodeco/validgen/internal/common" - "golang.org/x/text/cases" - "golang.org/x/text/language" -) - -type testCase struct { - validation string - normalizedType string - validCase string - invalidCase string - errorMessage string - generateOnly string -} - -var testCases = []struct { - operation string - testCases []testCase -}{ - // email operations - { - operation: "email", - testCases: []testCase{ - { - // email: "" - validation: `email`, - normalizedType: ``, - validCase: `"abcde@example.com"`, - invalidCase: `"abcde@example"`, - errorMessage: `{{.FieldName}} must be a valid email`, - }, - }, - }, - - // required operations - { - operation: "required", - testCases: []testCase{ - // required: "", "", "", "" - { - validation: `required`, - normalizedType: ``, - validCase: `"abcde"`, - invalidCase: `""`, - errorMessage: `{{.FieldName}} is required`, - }, - { - validation: `required`, - normalizedType: ``, - validCase: `32`, - invalidCase: `0`, - errorMessage: `{{.FieldName}} is required`, - }, - { - validation: `required`, - normalizedType: ``, - validCase: `12.34`, - invalidCase: `0`, - errorMessage: `{{.FieldName}} is required`, - }, - { - validation: `required`, - normalizedType: ``, - validCase: `true`, - invalidCase: `false`, - errorMessage: `{{.FieldName}} is required`, - }, - - // required: "[]", "[]", "[]", "[]" - { - validation: `required`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{"abcde"}`, - invalidCase: `{{.BasicType}}{}`, - errorMessage: `{{.FieldName}} must not be empty`, - }, - { - validation: `required`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{32}`, - invalidCase: `{{.BasicType}}{}`, - errorMessage: `{{.FieldName}} must not be empty`, - }, - { - validation: `required`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{12.34}`, - invalidCase: `{{.BasicType}}{}`, - errorMessage: `{{.FieldName}} must not be empty`, - }, - { - validation: `required`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{true}`, - invalidCase: `{{.BasicType}}{}`, - errorMessage: `{{.FieldName}} must not be empty`, - }, - - // required: "[N]", "[N]", "[N]", "[N]" - { - validation: `required`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{"abcde"}`, - invalidCase: `--`, - errorMessage: `{{.FieldName}} must not be empty`, - generateOnly: "pointer", - }, - { - validation: `required`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{32}`, - invalidCase: `--`, - errorMessage: `{{.FieldName}} must not be empty`, - generateOnly: "pointer", - }, - { - validation: `required`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{12.34}`, - invalidCase: `--`, - errorMessage: `{{.FieldName}} must not be empty`, - generateOnly: "pointer", - }, - { - validation: `required`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{true}`, - invalidCase: `--`, - errorMessage: `{{.FieldName}} must not be empty`, - generateOnly: "pointer", - }, - - // required: "map[]", "map[]", "map[]", "map[]" - { - validation: `required`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{"abcde":"value"}`, - invalidCase: `{{.BasicType}}{}`, - errorMessage: `{{.FieldName}} must not be empty`, - }, - { - validation: `required`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{32:64}`, - invalidCase: `{{.BasicType}}{}`, - errorMessage: `{{.FieldName}} must not be empty`, - }, - { - validation: `required`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{12.34:56.78}`, - invalidCase: `{{.BasicType}}{}`, - errorMessage: `{{.FieldName}} must not be empty`, - }, - { - validation: `required`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{true:true}`, - invalidCase: `{{.BasicType}}{}`, - errorMessage: `{{.FieldName}} must not be empty`, - }, - }, - }, - - // eq operations - { - operation: "eq", - testCases: []testCase{ - // eq: "", "", "", "" - { - validation: `eq=abcde`, - normalizedType: ``, - validCase: `"abcde"`, - invalidCase: `"fghij"`, - errorMessage: `{{.FieldName}} must be equal to 'abcde'`, - }, - { - validation: `eq=32`, - normalizedType: ``, - validCase: `32`, - invalidCase: `64`, - errorMessage: `{{.FieldName}} must be equal to 32`, - }, - { - validation: `eq=12.34`, - normalizedType: ``, - validCase: `12.34`, - invalidCase: `34.56`, - errorMessage: `{{.FieldName}} must be equal to 12.34`, - }, - { - validation: `eq=true`, - normalizedType: ``, - validCase: `true`, - invalidCase: `false`, - errorMessage: `{{.FieldName}} must be equal to true`, - }, - }, - }, - - // neq operations - { - operation: "neq", - testCases: []testCase{ - // neq: "", "", "", "" - { - validation: `neq=abcde`, - normalizedType: ``, - validCase: `"fghij"`, - invalidCase: `"abcde"`, - errorMessage: `{{.FieldName}} must not be equal to 'abcde'`, - }, - { - validation: `neq=32`, - normalizedType: ``, - validCase: `64`, - invalidCase: `32`, - errorMessage: `{{.FieldName}} must not be equal to 32`, - }, - { - validation: `neq=12.34`, - normalizedType: ``, - validCase: `34.56`, - invalidCase: `12.34`, - errorMessage: `{{.FieldName}} must not be equal to 12.34`, - }, - { - validation: `neq=true`, - normalizedType: ``, - validCase: `false`, - invalidCase: `true`, - errorMessage: `{{.FieldName}} must not be equal to true`, - }, - }, - }, - - // gt operations - { - operation: "gt", - testCases: []testCase{ - // gt: "", "" - { - validation: `gt=32`, - normalizedType: ``, - validCase: `33`, - invalidCase: `31`, - errorMessage: `{{.FieldName}} must be > 32`, - }, - { - validation: `gt=12.34`, - normalizedType: ``, - validCase: `12.35`, - invalidCase: `12.34`, - errorMessage: `{{.FieldName}} must be > 12.34`, - }, - }, - }, - - // gte operations - { - operation: "gte", - testCases: []testCase{ - // gte: "", "" - { - validation: `gte=32`, - normalizedType: ``, - validCase: `32`, - invalidCase: `31`, - errorMessage: `{{.FieldName}} must be >= 32`, - }, - { - validation: `gte=12.34`, - normalizedType: ``, - validCase: `12.34`, - invalidCase: `12.33`, - errorMessage: `{{.FieldName}} must be >= 12.34`, - }, - }, - }, - - // lt operations - { - operation: "lt", - testCases: []testCase{ - // lt: "", "" - { - validation: `lt=32`, - normalizedType: ``, - validCase: `31`, - invalidCase: `33`, - errorMessage: `{{.FieldName}} must be < 32`, - }, - { - validation: `lt=12.34`, - normalizedType: ``, - validCase: `12.33`, - invalidCase: `12.35`, - errorMessage: `{{.FieldName}} must be < 12.34`, - }, - }, - }, - - // lte operations - { - operation: "lte", - testCases: []testCase{ - // lte: "", "" - { - validation: `lte=32`, - normalizedType: ``, - validCase: `32`, - invalidCase: `33`, - errorMessage: `{{.FieldName}} must be <= 32`, - }, - { - validation: `lte=12.34`, - normalizedType: ``, - validCase: `12.34`, - invalidCase: `12.35`, - errorMessage: `{{.FieldName}} must be <= 12.34`, - }, - }, - }, - - // min operations - { - operation: "min", - testCases: []testCase{ - // min: "" - { - validation: `min=5`, - normalizedType: ``, - validCase: `"abcde"`, - invalidCase: `"abc"`, - errorMessage: `{{.FieldName}} length must be >= 5`, - }, - - // min: "[]", "[]", "[]", "[]" - { - validation: `min=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{"abc", "def"}`, - invalidCase: `{{.BasicType}}{"abc"}`, - errorMessage: `{{.FieldName}} must have at least 2 elements`, - }, - { - validation: `min=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{65, 67}`, - invalidCase: `{{.BasicType}}{65}`, - errorMessage: `{{.FieldName}} must have at least 2 elements`, - }, - { - validation: `min=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{65.65, 67.67}`, - invalidCase: `{{.BasicType}}{65.65}`, - errorMessage: `{{.FieldName}} must have at least 2 elements`, - }, - { - validation: `min=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{true, false}`, - invalidCase: `{{.BasicType}}{true}`, - errorMessage: `{{.FieldName}} must have at least 2 elements`, - }, - - // min: "map[]", "map[]", "map[]", "map[]" - { - validation: `min=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{"a": "1", "b": "2"}`, - invalidCase: `{{.BasicType}}{"a": "1"}`, - errorMessage: `{{.FieldName}} must have at least 2 elements`, - }, - { - validation: `min=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{1: 65, 2: 67}`, - invalidCase: `{{.BasicType}}{1: 65}`, - errorMessage: `{{.FieldName}} must have at least 2 elements`, - }, - { - validation: `min=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{1: 65.65, 2: 67.67}`, - invalidCase: `{{.BasicType}}{1: 65.65}`, - errorMessage: `{{.FieldName}} must have at least 2 elements`, - }, - { - validation: `min=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{true: true, false: false}`, - invalidCase: `{{.BasicType}}{true: true}`, - errorMessage: `{{.FieldName}} must have at least 2 elements`, - }, - }, - }, - - // max operations - { - operation: "max", - testCases: []testCase{ - // max: "" - { - validation: `max=3`, - normalizedType: ``, - validCase: `"abc"`, - invalidCase: `"abcde"`, - errorMessage: `{{.FieldName}} length must be <= 3`, - }, - - // max: "[]", "[]", "[]", "[]" - { - validation: `max=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{"abc", "def"}`, - invalidCase: `{{.BasicType}}{"abc", "def", "ghi"}`, - errorMessage: `{{.FieldName}} must have at most 2 elements`, - }, - { - validation: `max=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{65, 67}`, - invalidCase: `{{.BasicType}}{65, 66, 67}`, - errorMessage: `{{.FieldName}} must have at most 2 elements`, - }, - { - validation: `max=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{65.65, 67.67}`, - invalidCase: `{{.BasicType}}{65.65, 66.66, 67.67}`, - errorMessage: `{{.FieldName}} must have at most 2 elements`, - }, - { - validation: `max=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{true, false}`, - invalidCase: `{{.BasicType}}{true, false, true}`, - errorMessage: `{{.FieldName}} must have at most 2 elements`, - }, - - // max: "map[]", "map[]", "map[]", "map[]" - { - validation: `max=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{"a": "1", "b": "2"}`, - invalidCase: `{{.BasicType}}{"a": "1", "b": "2", "c": "3"}`, - errorMessage: `{{.FieldName}} must have at most 2 elements`, - }, - { - validation: `max=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{1: 65, 2: 67}`, - invalidCase: `{{.BasicType}}{1: 65, 2: 67, 3: 68}`, - errorMessage: `{{.FieldName}} must have at most 2 elements`, - }, - { - validation: `max=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{1: 65.65, 2: 67.67}`, - invalidCase: `{{.BasicType}}{1: 65.65, 2: 66.66, 3: 67.67}`, - errorMessage: `{{.FieldName}} must have at most 2 elements`, - }, - { - validation: `max=1`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{true: true}`, - invalidCase: `{{.BasicType}}{true: true, false: false}`, - errorMessage: `{{.FieldName}} must have at most 1 elements`, - }, - }, - }, - - // eq_ignore_case operations - { - operation: "eq_ignore_case", - testCases: []testCase{ - // eq_ignore_case: "" - { - validation: `eq_ignore_case=abcde`, - normalizedType: ``, - validCase: `"AbCdE"`, - invalidCase: `"a1b2c3"`, - errorMessage: `{{.FieldName}} must be equal to 'abcde'`, - }, - }, - }, - - // neq_ignore_case operations - { - operation: "neq_ignore_case", - testCases: []testCase{ - // neq_ignore_case: "" - { - validation: `neq_ignore_case=abcde`, - normalizedType: ``, - validCase: `"a1b2c3"`, - invalidCase: `"AbCdE"`, - errorMessage: `{{.FieldName}} must not be equal to 'abcde'`, - }, - }, - }, - - // len operations - { - operation: "len", - testCases: []testCase{ - // len: "" - { - validation: `len=2`, - normalizedType: ``, - validCase: `"ab"`, - invalidCase: `"abcde"`, - errorMessage: `{{.FieldName}} length must be 2`, - }, - - // len: "[]", "[]", "[]", "[]" - { - validation: `len=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{"abc", "def"}`, - invalidCase: `{{.BasicType}}{"abc", "def", "ghi"}`, - errorMessage: `{{.FieldName}} must have exactly 2 elements`, - }, - { - validation: `len=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{65, 67}`, - invalidCase: `{{.BasicType}}{65, 66, 67}`, - errorMessage: `{{.FieldName}} must have exactly 2 elements`, - }, - { - validation: `len=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{65.65, 67.67}`, - invalidCase: `{{.BasicType}}{65.65, 66.66, 67.67}`, - errorMessage: `{{.FieldName}} must have exactly 2 elements`, - }, - { - validation: `len=2`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{true, false}`, - invalidCase: `{{.BasicType}}{true, false, true}`, - errorMessage: `{{.FieldName}} must have exactly 2 elements`, - }, - - // len: "map[]", "map[]", "map[]", "map[]" - { - validation: `len=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{"a": "1", "b": "2"}`, - invalidCase: `{{.BasicType}}{"a": "1", "b": "2", "c": "3"}`, - errorMessage: `{{.FieldName}} must have exactly 2 elements`, - }, - { - validation: `len=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{1: 65, 2: 67}`, - invalidCase: `{{.BasicType}}{1: 65, 2: 67, 3: 68}`, - errorMessage: `{{.FieldName}} must have exactly 2 elements`, - }, - { - validation: `len=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{1: 65.65, 2: 67.67}`, - invalidCase: `{{.BasicType}}{1: 65.65, 2: 66.66, 3: 67.67}`, - errorMessage: `{{.FieldName}} must have exactly 2 elements`, - }, - { - validation: `len=2`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{true: true, false: false}`, - invalidCase: `{{.BasicType}}{true: true}`, - errorMessage: `{{.FieldName}} must have exactly 2 elements`, - }, - }, - }, - - // in operations - { - operation: "in", - testCases: []testCase{ - // in: "", "", "", "" - { - validation: `in=ab cd ef`, - normalizedType: ``, - validCase: `"cd"`, - invalidCase: `"fg"`, - errorMessage: `{{.FieldName}} must be one of 'ab' 'cd' 'ef'`, - }, - { - validation: `in=12 34 56`, - normalizedType: ``, - validCase: `34`, - invalidCase: `78`, - errorMessage: `{{.FieldName}} must be one of '12' '34' '56'`, - }, - { - validation: `in=11.11 22.22 33.33`, - normalizedType: ``, - validCase: `22.22`, - invalidCase: `44.44`, - errorMessage: `{{.FieldName}} must be one of '11.11' '22.22' '33.33'`, - }, - { - validation: `in=true`, - normalizedType: ``, - validCase: `true`, - invalidCase: `false`, - errorMessage: `{{.FieldName}} must be one of 'true'`, - }, - - // in: "[]", "[]", "[]", "[]" - { - validation: `in=ab cd ef`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{"ab", "ef"}`, - invalidCase: `{{.BasicType}}{"ab", "gh", "ef"}`, - errorMessage: `{{.FieldName}} elements must be one of 'ab' 'cd' 'ef'`, - }, - { - validation: `in=12 34 56`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{12, 56}`, - invalidCase: `{{.BasicType}}{12, 78, 56}`, - errorMessage: `{{.FieldName}} elements must be one of '12' '34' '56'`, - }, - { - validation: `in=11.11 22.22 33.33`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{11.11, 22.22}`, - invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, - errorMessage: `{{.FieldName}} elements must be one of '11.11' '22.22' '33.33'`, - }, - { - validation: `in=true`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{true, true}`, - invalidCase: `{{.BasicType}}{true, false, true}`, - errorMessage: `{{.FieldName}} elements must be one of 'true'`, - }, - - // in: "[]", "[]", "[]", "[]" - { - validation: `in=ab cd ef`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{"ab", "ef", "ab"}`, - invalidCase: `{{.BasicType}}{"ab", "gh", "ef"}`, - errorMessage: `{{.FieldName}} elements must be one of 'ab' 'cd' 'ef'`, - }, - { - validation: `in=12 34 56`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{12, 56, 12}`, - invalidCase: `{{.BasicType}}{12, 78, 56}`, - errorMessage: `{{.FieldName}} elements must be one of '12' '34' '56'`, - }, - { - validation: `in=11.11 22.22 33.33`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{11.11, 22.22, 11.11}`, - invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, - errorMessage: `{{.FieldName}} elements must be one of '11.11' '22.22' '33.33'`, - }, - { - validation: `in=true`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{true, true, true}`, - invalidCase: `{{.BasicType}}{true, false, true}`, - errorMessage: `{{.FieldName}} elements must be one of 'true'`, - }, - - // in: "map[]", "map[]", "map[]", "map[]" - { - validation: `in=a b c`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{"a": "1", "b": "2", "c": "3"}`, - invalidCase: `{{.BasicType}}{"a": "1", "d": "9", "c": "3"}`, - errorMessage: `{{.FieldName}} elements must be one of 'a' 'b' 'c'`, - }, - { - validation: `in=1 2 3`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{1: 65, 2: 67, 3: 68}`, - invalidCase: `{{.BasicType}}{1: 65, 4: 69, 3: 68}`, - errorMessage: `{{.FieldName}} elements must be one of '1' '2' '3'`, - }, - { - validation: `in=11.11 22.22 33.33`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{11.11: 11.11, 22.22: 22.22, 33.33: 33.33}`, - invalidCase: `{{.BasicType}}{11.11: 11.11, 44.44: 44.44, 33.33: 33.33}`, - errorMessage: `{{.FieldName}} elements must be one of '11.11' '22.22' '33.33'`, - }, - { - validation: `in=false`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{false: false}`, - invalidCase: `{{.BasicType}}{true: true, false: false}`, - errorMessage: `{{.FieldName}} elements must be one of 'false'`, - }, - }, - }, - - // nin operations - { - operation: "nin", - testCases: []testCase{ - // nin: "[]", "[]", "[]", "[]" - { - validation: `nin=ab cd ef`, - normalizedType: ``, - validCase: `"fg"`, - invalidCase: `"cd"`, - errorMessage: `{{.FieldName}} must not be one of 'ab' 'cd' 'ef'`, - }, - { - validation: `nin=12 34 56`, - normalizedType: ``, - validCase: `78`, - invalidCase: `34`, - errorMessage: `{{.FieldName}} must not be one of '12' '34' '56'`, - }, - { - validation: `nin=11.11 22.22 33.33`, - normalizedType: ``, - validCase: `44.44`, - invalidCase: `22.22`, - errorMessage: `{{.FieldName}} must not be one of '11.11' '22.22' '33.33'`, - }, - { - validation: `nin=true`, - normalizedType: ``, - validCase: `false`, - invalidCase: `true`, - errorMessage: `{{.FieldName}} must not be one of 'true'`, - }, - - // nin: "[]", "[]", "[]", "[]" - { - validation: `nin=ab cd ef`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{"gh", "ij", "kl"}`, - invalidCase: `{{.BasicType}}{"ab", "ef"}`, - errorMessage: `{{.FieldName}} elements must not be one of 'ab' 'cd' 'ef'`, - }, - { - validation: `nin=12 34 56`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{78, 91}`, - invalidCase: `{{.BasicType}}{12, 78, 56}`, - errorMessage: `{{.FieldName}} elements must not be one of '12' '34' '56'`, - }, - { - validation: `nin=11.11 22.22 33.33`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{44.44, 55.55, 66.66}`, - invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, - errorMessage: `{{.FieldName}} elements must not be one of '11.11' '22.22' '33.33'`, - }, - { - validation: `nin=true`, - normalizedType: `[]`, - validCase: `{{.BasicType}}{false, false, false}`, - invalidCase: `{{.BasicType}}{true, false, true}`, - errorMessage: `{{.FieldName}} elements must not be one of 'true'`, - }, - - // nin: "[]", "[]", "[]", "[]" - { - validation: `nin=ab cd ef`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{"gh", "ij", "kl"}`, - invalidCase: `{{.BasicType}}{"ab", "gh", "ef"}`, - errorMessage: `{{.FieldName}} elements must not be one of 'ab' 'cd' 'ef'`, - }, - { - validation: `nin=12 34 56`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{78, 91, 23}`, - invalidCase: `{{.BasicType}}{12, 78, 56}`, - errorMessage: `{{.FieldName}} elements must not be one of '12' '34' '56'`, - }, - { - validation: `nin=11.11 22.22 33.33`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{44.44, 55.55, 66.66}`, - invalidCase: `{{.BasicType}}{11.11, 44.44, 33.33}`, - errorMessage: `{{.FieldName}} elements must not be one of '11.11' '22.22' '33.33'`, - }, - { - validation: `nin=true`, - normalizedType: `[N]`, - validCase: `{{.BasicType}}{false, false, false}`, - invalidCase: `{{.BasicType}}{true, false, true}`, - errorMessage: `{{.FieldName}} elements must not be one of 'true'`, - }, - - // nin: "map[]", "map[]", "map[]", "map[]" - { - validation: `nin=a b c`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{"d": "1", "e": "2", "f": "3"}`, - invalidCase: `{{.BasicType}}{"a": "1", "d": "9", "c": "3"}`, - errorMessage: `{{.FieldName}} elements must not be one of 'a' 'b' 'c'`, - }, - { - validation: `nin=1 2 3`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{5: 55, 6: 66, 7: 77}`, - invalidCase: `{{.BasicType}}{1: 11, 4: 44, 3: 33}`, - errorMessage: `{{.FieldName}} elements must not be one of '1' '2' '3'`, - }, - { - validation: `nin=11.11 22.22 33.33`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{44.44: 44.44, 55.55: 55.55, 66.66: 66.66}`, - invalidCase: `{{.BasicType}}{11.11: 11.11, 44.44: 44.44, 33.33: 33.33}`, - errorMessage: `{{.FieldName}} elements must not be one of '11.11' '22.22' '33.33'`, - }, - { - validation: `nin=false`, - normalizedType: `map[]`, - validCase: `{{.BasicType}}{true: true}`, - invalidCase: `{{.BasicType}}{true: true, false: false}`, - errorMessage: `{{.FieldName}} elements must not be one of 'false'`, - }, - }, - }, -} - -type AllTestCasesToGenerate struct { - TestCases []TestCaseToGenerate -} - -type TestCaseToGenerate struct { - StructName string - Tests []TestCase -} - -type TestCase struct { - FieldName string - Validation string - FieldType string - BasicType string - ValidCase string - InvalidCase string - ErrorMessage string -} - -func generateTestCases() { - generateTestCasesFile("no_pointer_tests.tpl", "generated_no_pointer_tests.go", false) - generateTestCasesFile("pointer_tests.tpl", "generated_pointer_tests.go", true) -} - -func generateTestCasesFile(tpl, dest string, pointer bool) { - log.Printf("Generating test cases file: tpl[%s] dest[%s] pointer[%v]\n", tpl, dest, pointer) - - allTestsToGenerate := AllTestCasesToGenerate{} - - for _, testCase := range testCases { - structName := testCase.operation + "StructFields" - if pointer { - structName += "Pointer" - } - allTestsToGenerate.TestCases = append(allTestsToGenerate.TestCases, TestCaseToGenerate{ - StructName: structName, - }) - for _, toGenerate := range testCase.testCases { - // Default ("") gen no pointer and pointer test. - if toGenerate.generateOnly != "" { - if toGenerate.generateOnly == "pointer" && !pointer { - continue - } - if toGenerate.generateOnly == "nopointer" && pointer { - continue - } - } - normalizedType := toGenerate.normalizedType - if pointer { - normalizedType = "*" + normalizedType - } - fTypes := common.HelperFromNormalizedToBasicTypes(normalizedType) - sNames := common.HelperFromNormalizedToStringNames(normalizedType) - for i := range fTypes { - op, _, _ := strings.Cut(toGenerate.validation, "=") - fieldName := "Field" + cases.Title(language.Und).String(op) + sNames[i] - basicType, _ := strings.CutPrefix(fTypes[i], "*") - allTestsToGenerate.TestCases[len(allTestsToGenerate.TestCases)-1].Tests = append(allTestsToGenerate.TestCases[len(allTestsToGenerate.TestCases)-1].Tests, TestCase{ - FieldName: fieldName, - Validation: toGenerate.validation, - FieldType: fTypes[i], - BasicType: basicType, - ValidCase: strings.ReplaceAll(toGenerate.validCase, "{{.BasicType}}", basicType), - InvalidCase: strings.ReplaceAll(toGenerate.invalidCase, "{{.BasicType}}", basicType), - ErrorMessage: strings.ReplaceAll(toGenerate.errorMessage, "{{.FieldName}}", fieldName), - }) - } - } - } - - if err := allTestsToGenerate.GenerateFile(tpl, dest); err != nil { - log.Fatalf("error generation usecases file %s", err) - - } - - log.Printf("Generating %s done\n", dest) -} - -func (at *AllTestCasesToGenerate) GenerateFile(tplFile, output string) error { - tpl, err := os.ReadFile(tplFile) - if err != nil { - return fmt.Errorf("error reading %s: %s", tplFile, err) - } - - tmpl, err := template.New("UsecaseTests").Parse(string(tpl)) - if err != nil { - return err - } - - code := new(bytes.Buffer) - if err := tmpl.Execute(code, at); err != nil { - return err - } - - formattedCode, err := format.Source(code.Bytes()) - if err != nil { - return err - } - - if err := os.WriteFile(output, formattedCode, 0644); err != nil { - return err - } - - return nil -} diff --git a/tests/endtoend/generate_tests/no_pointer_tests.tpl b/tests/endtoend/generate_tests/no_pointer_tests.tpl deleted file mode 100644 index 8badfdf..0000000 --- a/tests/endtoend/generate_tests/no_pointer_tests.tpl +++ /dev/null @@ -1,50 +0,0 @@ -// Code generated by TestGenerator. DO NOT EDIT. - -package main - -import ( - "log" -) - -func noPointerTests() { -{{range .TestCases}}{{.StructName}}Tests() -{{end}} -} - -{{range .TestCases}} - -type {{.StructName}} struct { - {{range .Tests}}{{.FieldName}} {{.FieldType}} `valid:"{{.Validation}}"` - {{end}} -} - -func {{.StructName}}Tests() { - log.Println("starting {{.StructName}} types tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios (invalid cases) - v := &{{.StructName}}{} - expectedMsgErrors = []string{ - {{range .Tests}}"{{.ErrorMessage}}", - {{end}} - } - - {{range .Tests}}{{ if ne .InvalidCase "--" }}v.{{.FieldName}} = {{.InvalidCase}}{{end}} - {{end}} - errs = {{.StructName}}Validate(v) - assertExpectedErrorMsgs("testcase 1", errs, expectedMsgErrors) - - // Test case 2: All valid cases - v = &{{.StructName}}{} - {{range .Tests}}v.{{.FieldName}} = {{.ValidCase}} - {{end}} - expectedMsgErrors = nil - errs = {{.StructName}}Validate(v) - assertExpectedErrorMsgs("testcase 2", errs, expectedMsgErrors) - - log.Println("{{.StructName}} types tests ok") -} - -{{end}} \ No newline at end of file diff --git a/tests/endtoend/generate_tests/numeric_float.tpl b/tests/endtoend/generate_tests/numeric_float.tpl deleted file mode 100644 index ff3d884..0000000 --- a/tests/endtoend/generate_tests/numeric_float.tpl +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by TestGenerator. DO NOT EDIT. - -package main - -import "log" - -func numericFloatTypeTests() { - log.Println("starting numeric float tests") - - {{range .FieldTypes}}numeric{{. | title }}Tests() - {{end}} - log.Println("numeric float tests ok") -} -{{range .FieldTypes}} -type NumericType{{. | title }} struct { - FieldReq {{.}} `valid:"required"` - FieldEq {{.}} `valid:"eq=5.9"` - FieldNeq {{.}} `valid:"neq=5.9"` - FieldGt {{.}} `valid:"gt=10.1"` - FieldGte {{.}} `valid:"gte=10.1"` - FieldLt {{.}} `valid:"lt=9.9"` - FieldLte {{.}} `valid:"lte=9.9"` - FieldIn {{.}} `valid:"in=5.1 6.2 7.3"` - FieldNotIn {{.}} `valid:"nin=8.5 9.6 10.7"` -} - -func numeric{{. | title }}Tests() { - log.Println("starting numeric {{.}} tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericType{{. | title }}{ - FieldReq: 0, - FieldEq: 1.2, - FieldNeq: 5.9, - FieldGt: 8.1, - FieldGte: 8.1, - FieldLt: 12.2, - FieldLte: 12.2, - FieldIn: 3.123, - FieldNotIn: 9.6, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5.9", - "FieldNeq must not be equal to 5.9", - "FieldGt must be > 10.1", - "FieldGte must be >= 10.1", - "FieldLt must be < 9.9", - "FieldLte must be <= 9.9", - "FieldIn must be one of '5.1' '6.2' '7.3'", - "FieldNotIn must not be one of '8.5' '9.6' '10.7'", - } - errs = NumericType{{. | title }}Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericType{{. | title }}{ - FieldReq: 123, - FieldEq: 5.9, - FieldNeq: 2.4, - FieldGt: 11.1, - FieldGte: 12.1, - FieldLt: 9.1, - FieldLte: 8.1, - FieldIn: 6.2, - FieldNotIn: 12.4, - } - expectedMsgErrors = nil - errs = NumericType{{. | title }}Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric {{.}} tests ok") -} -{{end}} \ No newline at end of file diff --git a/tests/endtoend/generate_tests/numeric_int.tpl b/tests/endtoend/generate_tests/numeric_int.tpl deleted file mode 100644 index cc28723..0000000 --- a/tests/endtoend/generate_tests/numeric_int.tpl +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by TestGenerator. DO NOT EDIT. - -package main - -import "log" - -func numericIntTypeTests() { - log.Println("starting numeric int tests") - - {{range .FieldTypes}}numeric{{. | title }}Tests() - {{end}} - log.Println("numeric int tests ok") -} -{{range .FieldTypes}} -type NumericType{{. | title }} struct { - FieldReq {{.}} `valid:"required"` - FieldEq {{.}} `valid:"eq=5"` - FieldNeq {{.}} `valid:"neq=5"` - FieldGt {{.}} `valid:"gt=10"` - FieldGte {{.}} `valid:"gte=10"` - FieldLt {{.}} `valid:"lt=10"` - FieldLte {{.}} `valid:"lte=10"` - FieldIn {{.}} `valid:"in=5 6 7"` - FieldNotIn {{.}} `valid:"nin=8 9 10"` -} - -func numeric{{. | title }}Tests() { - log.Println("starting numeric {{.}} tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericType{{. | title }}{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericType{{. | title }}Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericType{{. | title }}{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericType{{. | title }}Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric {{.}} tests ok") -} -{{end}} \ No newline at end of file diff --git a/tests/endtoend/generate_tests/pointer_tests.tpl b/tests/endtoend/generate_tests/pointer_tests.tpl deleted file mode 100644 index 6528758..0000000 --- a/tests/endtoend/generate_tests/pointer_tests.tpl +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by TestGenerator. DO NOT EDIT. - -package main - -import ( - "log" -) - -func pointerTests() { -{{range .TestCases}}{{.StructName}}Tests() -{{end}} -} - -{{range .TestCases}} - -type {{.StructName}} struct { - {{range .Tests}}{{.FieldName}} {{.FieldType}} `valid:"{{.Validation}}"` - {{end}} -} - -func {{.StructName}}Tests() { - log.Println("starting {{.StructName}} types tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios (nil values) - v := &{{.StructName}}{} - expectedMsgErrors = []string{ - {{range .Tests}}"{{.ErrorMessage}}", - {{end}} - } - errs = {{.StructName}}Validate(v) - assertExpectedErrorMsgs("testcase 1", errs, expectedMsgErrors) - - // Test case 2: All failure scenarios (invalid cases) - {{range .Tests}}{{ if ne .InvalidCase "--" }}var Invalid{{.FieldName}} {{.BasicType}} = {{.InvalidCase}}{{end}} - {{end}} - v = &{{.StructName}}{} - {{range .Tests}}{{ if ne .InvalidCase "--" }}v.{{.FieldName}} = &Invalid{{.FieldName}}{{end}} - {{end}} - errs = {{.StructName}}Validate(v) - assertExpectedErrorMsgs("testcase 2", errs, expectedMsgErrors) - - // Test case 3: All valid cases - {{range .Tests}}var Valid{{.FieldName}} {{.BasicType}} = {{.ValidCase}} - {{end}} - v = &{{.StructName}}{} - {{range .Tests}}v.{{.FieldName}} = &Valid{{.FieldName}} - {{end}} - expectedMsgErrors = nil - errs = {{.StructName}}Validate(v) - assertExpectedErrorMsgs("testcase 3", errs, expectedMsgErrors) - - log.Println("{{.StructName}} types tests ok") -} - -{{end}} \ No newline at end of file From 78ed57abe1e9abaa0533292644ebd464e2992374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Sandro=20Garz=C3=A3o?= Date: Fri, 7 Nov 2025 20:29:24 -0300 Subject: [PATCH 28/31] chore: remove old end-to-end tests generated by hand --- tests/endtoend/array_string.go | 44 -- .../endtoend/generated_numeric_float_tests.go | 148 ---- tests/endtoend/generated_numeric_int_tests.go | 692 ------------------ tests/endtoend/main.go | 8 - tests/endtoend/map_numeric.go | 60 -- tests/endtoend/map_string.go | 60 -- tests/endtoend/slice_integer.go | 60 -- tests/endtoend/slice_string.go | 60 -- tests/endtoend/string.go | 73 -- tests/endtoend/validator__.go | 510 ------------- 10 files changed, 1715 deletions(-) delete mode 100644 tests/endtoend/array_string.go delete mode 100644 tests/endtoend/generated_numeric_float_tests.go delete mode 100644 tests/endtoend/generated_numeric_int_tests.go delete mode 100644 tests/endtoend/map_numeric.go delete mode 100644 tests/endtoend/map_string.go delete mode 100644 tests/endtoend/slice_integer.go delete mode 100644 tests/endtoend/slice_string.go delete mode 100644 tests/endtoend/string.go diff --git a/tests/endtoend/array_string.go b/tests/endtoend/array_string.go deleted file mode 100644 index ad076a4..0000000 --- a/tests/endtoend/array_string.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "log" -) - -type ArrayString struct { - TypesIn [8]string `valid:"in=a b c"` - TypesNotIn [8]string `valid:"nin=a b c"` -} - -func arrayStringTests() { - log.Println("starting array string tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &ArrayString{ - TypesIn: [8]string{"d"}, - TypesNotIn: [8]string{"a", "b", "c", "d", "e", "f", "g", "h"}, - } - expectedMsgErrors = []string{ - "TypesIn elements must be one of 'a' 'b' 'c'", - "TypesNotIn elements must not be one of 'a' 'b' 'c'", - } - errs = ArrayStringValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &ArrayString{ - TypesIn: [8]string{"a", "b", "c", "a", "b", "c", "a", "b"}, - TypesNotIn: [8]string{"d", "e", "f", "d", "e", "f", "d", "e"}, - } - expectedMsgErrors = nil - errs = ArrayStringValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("array string tests ok") -} diff --git a/tests/endtoend/generated_numeric_float_tests.go b/tests/endtoend/generated_numeric_float_tests.go deleted file mode 100644 index 1d45479..0000000 --- a/tests/endtoend/generated_numeric_float_tests.go +++ /dev/null @@ -1,148 +0,0 @@ -// Code generated by TestGenerator. DO NOT EDIT. - -package main - -import "log" - -func numericFloatTypeTests() { - log.Println("starting numeric float tests") - - numericFloat32Tests() - numericFloat64Tests() - - log.Println("numeric float tests ok") -} - -type NumericTypeFloat32 struct { - FieldReq float32 `valid:"required"` - FieldEq float32 `valid:"eq=5.9"` - FieldNeq float32 `valid:"neq=5.9"` - FieldGt float32 `valid:"gt=10.1"` - FieldGte float32 `valid:"gte=10.1"` - FieldLt float32 `valid:"lt=9.9"` - FieldLte float32 `valid:"lte=9.9"` - FieldIn float32 `valid:"in=5.1 6.2 7.3"` - FieldNotIn float32 `valid:"nin=8.5 9.6 10.7"` -} - -func numericFloat32Tests() { - log.Println("starting numeric float32 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeFloat32{ - FieldReq: 0, - FieldEq: 1.2, - FieldNeq: 5.9, - FieldGt: 8.1, - FieldGte: 8.1, - FieldLt: 12.2, - FieldLte: 12.2, - FieldIn: 3.123, - FieldNotIn: 9.6, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5.9", - "FieldNeq must not be equal to 5.9", - "FieldGt must be > 10.1", - "FieldGte must be >= 10.1", - "FieldLt must be < 9.9", - "FieldLte must be <= 9.9", - "FieldIn must be one of '5.1' '6.2' '7.3'", - "FieldNotIn must not be one of '8.5' '9.6' '10.7'", - } - errs = NumericTypeFloat32Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeFloat32{ - FieldReq: 123, - FieldEq: 5.9, - FieldNeq: 2.4, - FieldGt: 11.1, - FieldGte: 12.1, - FieldLt: 9.1, - FieldLte: 8.1, - FieldIn: 6.2, - FieldNotIn: 12.4, - } - expectedMsgErrors = nil - errs = NumericTypeFloat32Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric float32 tests ok") -} - -type NumericTypeFloat64 struct { - FieldReq float64 `valid:"required"` - FieldEq float64 `valid:"eq=5.9"` - FieldNeq float64 `valid:"neq=5.9"` - FieldGt float64 `valid:"gt=10.1"` - FieldGte float64 `valid:"gte=10.1"` - FieldLt float64 `valid:"lt=9.9"` - FieldLte float64 `valid:"lte=9.9"` - FieldIn float64 `valid:"in=5.1 6.2 7.3"` - FieldNotIn float64 `valid:"nin=8.5 9.6 10.7"` -} - -func numericFloat64Tests() { - log.Println("starting numeric float64 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeFloat64{ - FieldReq: 0, - FieldEq: 1.2, - FieldNeq: 5.9, - FieldGt: 8.1, - FieldGte: 8.1, - FieldLt: 12.2, - FieldLte: 12.2, - FieldIn: 3.123, - FieldNotIn: 9.6, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5.9", - "FieldNeq must not be equal to 5.9", - "FieldGt must be > 10.1", - "FieldGte must be >= 10.1", - "FieldLt must be < 9.9", - "FieldLte must be <= 9.9", - "FieldIn must be one of '5.1' '6.2' '7.3'", - "FieldNotIn must not be one of '8.5' '9.6' '10.7'", - } - errs = NumericTypeFloat64Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeFloat64{ - FieldReq: 123, - FieldEq: 5.9, - FieldNeq: 2.4, - FieldGt: 11.1, - FieldGte: 12.1, - FieldLt: 9.1, - FieldLte: 8.1, - FieldIn: 6.2, - FieldNotIn: 12.4, - } - expectedMsgErrors = nil - errs = NumericTypeFloat64Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric float64 tests ok") -} diff --git a/tests/endtoend/generated_numeric_int_tests.go b/tests/endtoend/generated_numeric_int_tests.go deleted file mode 100644 index 81d62c7..0000000 --- a/tests/endtoend/generated_numeric_int_tests.go +++ /dev/null @@ -1,692 +0,0 @@ -// Code generated by TestGenerator. DO NOT EDIT. - -package main - -import "log" - -func numericIntTypeTests() { - log.Println("starting numeric int tests") - - numericIntTests() - numericInt8Tests() - numericInt16Tests() - numericInt32Tests() - numericInt64Tests() - numericUintTests() - numericUint8Tests() - numericUint16Tests() - numericUint32Tests() - numericUint64Tests() - - log.Println("numeric int tests ok") -} - -type NumericTypeInt struct { - FieldReq int `valid:"required"` - FieldEq int `valid:"eq=5"` - FieldNeq int `valid:"neq=5"` - FieldGt int `valid:"gt=10"` - FieldGte int `valid:"gte=10"` - FieldLt int `valid:"lt=10"` - FieldLte int `valid:"lte=10"` - FieldIn int `valid:"in=5 6 7"` - FieldNotIn int `valid:"nin=8 9 10"` -} - -func numericIntTests() { - log.Println("starting numeric int tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeInt{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeIntValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeInt{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeIntValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric int tests ok") -} - -type NumericTypeInt8 struct { - FieldReq int8 `valid:"required"` - FieldEq int8 `valid:"eq=5"` - FieldNeq int8 `valid:"neq=5"` - FieldGt int8 `valid:"gt=10"` - FieldGte int8 `valid:"gte=10"` - FieldLt int8 `valid:"lt=10"` - FieldLte int8 `valid:"lte=10"` - FieldIn int8 `valid:"in=5 6 7"` - FieldNotIn int8 `valid:"nin=8 9 10"` -} - -func numericInt8Tests() { - log.Println("starting numeric int8 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeInt8{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeInt8Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeInt8{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeInt8Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric int8 tests ok") -} - -type NumericTypeInt16 struct { - FieldReq int16 `valid:"required"` - FieldEq int16 `valid:"eq=5"` - FieldNeq int16 `valid:"neq=5"` - FieldGt int16 `valid:"gt=10"` - FieldGte int16 `valid:"gte=10"` - FieldLt int16 `valid:"lt=10"` - FieldLte int16 `valid:"lte=10"` - FieldIn int16 `valid:"in=5 6 7"` - FieldNotIn int16 `valid:"nin=8 9 10"` -} - -func numericInt16Tests() { - log.Println("starting numeric int16 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeInt16{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeInt16Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeInt16{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeInt16Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric int16 tests ok") -} - -type NumericTypeInt32 struct { - FieldReq int32 `valid:"required"` - FieldEq int32 `valid:"eq=5"` - FieldNeq int32 `valid:"neq=5"` - FieldGt int32 `valid:"gt=10"` - FieldGte int32 `valid:"gte=10"` - FieldLt int32 `valid:"lt=10"` - FieldLte int32 `valid:"lte=10"` - FieldIn int32 `valid:"in=5 6 7"` - FieldNotIn int32 `valid:"nin=8 9 10"` -} - -func numericInt32Tests() { - log.Println("starting numeric int32 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeInt32{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeInt32Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeInt32{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeInt32Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric int32 tests ok") -} - -type NumericTypeInt64 struct { - FieldReq int64 `valid:"required"` - FieldEq int64 `valid:"eq=5"` - FieldNeq int64 `valid:"neq=5"` - FieldGt int64 `valid:"gt=10"` - FieldGte int64 `valid:"gte=10"` - FieldLt int64 `valid:"lt=10"` - FieldLte int64 `valid:"lte=10"` - FieldIn int64 `valid:"in=5 6 7"` - FieldNotIn int64 `valid:"nin=8 9 10"` -} - -func numericInt64Tests() { - log.Println("starting numeric int64 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeInt64{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeInt64Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeInt64{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeInt64Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric int64 tests ok") -} - -type NumericTypeUint struct { - FieldReq uint `valid:"required"` - FieldEq uint `valid:"eq=5"` - FieldNeq uint `valid:"neq=5"` - FieldGt uint `valid:"gt=10"` - FieldGte uint `valid:"gte=10"` - FieldLt uint `valid:"lt=10"` - FieldLte uint `valid:"lte=10"` - FieldIn uint `valid:"in=5 6 7"` - FieldNotIn uint `valid:"nin=8 9 10"` -} - -func numericUintTests() { - log.Println("starting numeric uint tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeUint{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeUintValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeUint{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeUintValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric uint tests ok") -} - -type NumericTypeUint8 struct { - FieldReq uint8 `valid:"required"` - FieldEq uint8 `valid:"eq=5"` - FieldNeq uint8 `valid:"neq=5"` - FieldGt uint8 `valid:"gt=10"` - FieldGte uint8 `valid:"gte=10"` - FieldLt uint8 `valid:"lt=10"` - FieldLte uint8 `valid:"lte=10"` - FieldIn uint8 `valid:"in=5 6 7"` - FieldNotIn uint8 `valid:"nin=8 9 10"` -} - -func numericUint8Tests() { - log.Println("starting numeric uint8 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeUint8{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeUint8Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeUint8{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeUint8Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric uint8 tests ok") -} - -type NumericTypeUint16 struct { - FieldReq uint16 `valid:"required"` - FieldEq uint16 `valid:"eq=5"` - FieldNeq uint16 `valid:"neq=5"` - FieldGt uint16 `valid:"gt=10"` - FieldGte uint16 `valid:"gte=10"` - FieldLt uint16 `valid:"lt=10"` - FieldLte uint16 `valid:"lte=10"` - FieldIn uint16 `valid:"in=5 6 7"` - FieldNotIn uint16 `valid:"nin=8 9 10"` -} - -func numericUint16Tests() { - log.Println("starting numeric uint16 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeUint16{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeUint16Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeUint16{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeUint16Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric uint16 tests ok") -} - -type NumericTypeUint32 struct { - FieldReq uint32 `valid:"required"` - FieldEq uint32 `valid:"eq=5"` - FieldNeq uint32 `valid:"neq=5"` - FieldGt uint32 `valid:"gt=10"` - FieldGte uint32 `valid:"gte=10"` - FieldLt uint32 `valid:"lt=10"` - FieldLte uint32 `valid:"lte=10"` - FieldIn uint32 `valid:"in=5 6 7"` - FieldNotIn uint32 `valid:"nin=8 9 10"` -} - -func numericUint32Tests() { - log.Println("starting numeric uint32 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeUint32{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeUint32Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeUint32{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeUint32Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric uint32 tests ok") -} - -type NumericTypeUint64 struct { - FieldReq uint64 `valid:"required"` - FieldEq uint64 `valid:"eq=5"` - FieldNeq uint64 `valid:"neq=5"` - FieldGt uint64 `valid:"gt=10"` - FieldGte uint64 `valid:"gte=10"` - FieldLt uint64 `valid:"lt=10"` - FieldLte uint64 `valid:"lte=10"` - FieldIn uint64 `valid:"in=5 6 7"` - FieldNotIn uint64 `valid:"nin=8 9 10"` -} - -func numericUint64Tests() { - log.Println("starting numeric uint64 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &NumericTypeUint64{ - FieldReq: 0, - FieldEq: 0, - FieldNeq: 5, - FieldGt: 8, - FieldGte: 8, - FieldLt: 12, - FieldLte: 12, - FieldIn: 3, - FieldNotIn: 9, - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 5", - "FieldNeq must not be equal to 5", - "FieldGt must be > 10", - "FieldGte must be >= 10", - "FieldLt must be < 10", - "FieldLte must be <= 10", - "FieldIn must be one of '5' '6' '7'", - "FieldNotIn must not be one of '8' '9' '10'", - } - errs = NumericTypeUint64Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &NumericTypeUint64{ - FieldReq: 123, - FieldEq: 5, - FieldNeq: 2, - FieldGt: 11, - FieldGte: 12, - FieldLt: 9, - FieldLte: 8, - FieldIn: 6, - FieldNotIn: 12, - } - expectedMsgErrors = nil - errs = NumericTypeUint64Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("numeric uint64 tests ok") -} diff --git a/tests/endtoend/main.go b/tests/endtoend/main.go index 8982f92..b9122c3 100644 --- a/tests/endtoend/main.go +++ b/tests/endtoend/main.go @@ -36,18 +36,10 @@ func main() { allTypes1Tests() allTypes2Tests() structInPkgTests() - stringTests() nestedStructTests() - sliceStringTests() - sliceIntegerTests() - arrayStringTests() cmpBetweenInnerFieldsTests() cmpBetweenNestedFieldsTests() boolTests() - mapStringTests() - mapUint8Tests() - numericIntTypeTests() - numericFloatTypeTests() pointerTests() noPointerTests() diff --git a/tests/endtoend/map_numeric.go b/tests/endtoend/map_numeric.go deleted file mode 100644 index 06f9adf..0000000 --- a/tests/endtoend/map_numeric.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "log" -) - -type MapUint8 struct { - FieldRequired map[uint8]string `valid:"required"` - FieldMin map[uint8]string `valid:"min=2"` - FieldMax map[uint8]string `valid:"max=5"` - FieldLen map[uint8]string `valid:"len=3"` - FieldIn map[uint8]string `valid:"in=1 2 3"` - FieldNotIn map[uint8]string `valid:"nin=1 2 3"` -} - -func mapUint8Tests() { - log.Println("starting map uint8 tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &MapUint8{ - FieldRequired: map[uint8]string{}, - FieldMin: map[uint8]string{1: "1"}, - FieldMax: map[uint8]string{1: "1", 2: "2", 3: "3", 4: "4", 5: "5", 6: "6"}, - FieldLen: map[uint8]string{1: "1", 2: "2"}, - FieldIn: map[uint8]string{4: "d"}, - FieldNotIn: map[uint8]string{1: "a", 2: "b"}, - } - expectedMsgErrors = []string{ - "FieldRequired must not be empty", - "FieldMin must have at least 2 elements", - "FieldMax must have at most 5 elements", - "FieldLen must have exactly 3 elements", - "FieldIn elements must be one of '1' '2' '3'", - "FieldNotIn elements must not be one of '1' '2' '3'", - } - errs = MapUint8Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &MapUint8{ - FieldRequired: map[uint8]string{1: "1", 2: "2"}, - FieldMin: map[uint8]string{1: "1", 2: "2"}, - FieldMax: map[uint8]string{1: "1", 2: "2", 3: "3", 4: "4"}, - FieldLen: map[uint8]string{1: "1", 2: "2", 3: "3"}, - FieldIn: map[uint8]string{1: "1", 2: "2", 3: "3"}, - FieldNotIn: map[uint8]string{4: "d", 5: "e", 6: "f"}, - } - expectedMsgErrors = nil - errs = MapUint8Validate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("map uint8 tests ok") -} diff --git a/tests/endtoend/map_string.go b/tests/endtoend/map_string.go deleted file mode 100644 index b5307e1..0000000 --- a/tests/endtoend/map_string.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "log" -) - -type MapString struct { - FieldRequired map[string]string `valid:"required"` - FieldMin map[string]string `valid:"min=2"` - FieldMax map[string]string `valid:"max=5"` - FieldLen map[string]string `valid:"len=3"` - FieldIn map[string]string `valid:"in=a b c"` - FieldNotIn map[string]string `valid:"nin=a b c"` -} - -func mapStringTests() { - log.Println("starting map string tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &MapString{ - FieldRequired: map[string]string{}, - FieldMin: map[string]string{"1": "1"}, - FieldMax: map[string]string{"1": "1", "2": "2", "3": "3", "4": "4", "5": "5", "6": "6"}, - FieldLen: map[string]string{"1": "1", "2": "2"}, - FieldIn: map[string]string{"d": "d"}, - FieldNotIn: map[string]string{"a": "a", "b": "b"}, - } - expectedMsgErrors = []string{ - "FieldRequired must not be empty", - "FieldMin must have at least 2 elements", - "FieldMax must have at most 5 elements", - "FieldLen must have exactly 3 elements", - "FieldIn elements must be one of 'a' 'b' 'c'", - "FieldNotIn elements must not be one of 'a' 'b' 'c'", - } - errs = MapStringValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &MapString{ - FieldRequired: map[string]string{"1": "1", "2": "2"}, - FieldMin: map[string]string{"1": "1", "2": "2"}, - FieldMax: map[string]string{"1": "1", "2": "2", "3": "3", "4": "4"}, - FieldLen: map[string]string{"1": "1", "2": "2", "3": "3"}, - FieldIn: map[string]string{"a": "a", "b": "b", "c": "c"}, - FieldNotIn: map[string]string{"d": "d", "e": "e", "f": "f"}, - } - expectedMsgErrors = nil - errs = MapStringValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("map string tests ok") -} diff --git a/tests/endtoend/slice_integer.go b/tests/endtoend/slice_integer.go deleted file mode 100644 index 45ce1f0..0000000 --- a/tests/endtoend/slice_integer.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "log" -) - -type SliceInteger struct { - TypesRequired []int `valid:"required"` - TypesMin []int `valid:"min=2"` - TypesMax []int `valid:"max=5"` - TypesLen []int `valid:"len=3"` - TypesIn []int `valid:"in=1 2 3"` - TypesNotIn []int `valid:"nin=1 2 3"` -} - -func sliceIntegerTests() { - log.Println("starting slice integer tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &SliceInteger{ - TypesRequired: []int{}, - TypesMin: []int{1}, - TypesMax: []int{1, 2, 3, 4, 5, 6}, - TypesLen: []int{1, 2}, - TypesIn: []int{4}, - TypesNotIn: []int{2, 3}, - } - expectedMsgErrors = []string{ - "TypesRequired must not be empty", - "TypesMin must have at least 2 elements", - "TypesMax must have at most 5 elements", - "TypesLen must have exactly 3 elements", - "TypesIn elements must be one of '1' '2' '3'", - "TypesNotIn elements must not be one of '1' '2' '3'", - } - errs = SliceIntegerValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &SliceInteger{ - TypesRequired: []int{1, 2}, - TypesMin: []int{1, 2}, - TypesMax: []int{1, 2, 3, 4}, - TypesLen: []int{1, 2, 3}, - TypesIn: []int{1, 2, 3, 1, 2, 3}, - TypesNotIn: []int{4, 5, 6}, - } - expectedMsgErrors = nil - errs = SliceIntegerValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("slice integer tests ok") -} diff --git a/tests/endtoend/slice_string.go b/tests/endtoend/slice_string.go deleted file mode 100644 index 2a7d426..0000000 --- a/tests/endtoend/slice_string.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "log" -) - -type SliceString struct { - TypesRequired []string `valid:"required"` - TypesMin []string `valid:"min=2"` - TypesMax []string `valid:"max=5"` - TypesLen []string `valid:"len=3"` - TypesIn []string `valid:"in=a b c"` - TypesNotIn []string `valid:"nin=a b c"` -} - -func sliceStringTests() { - log.Println("starting slice string tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &SliceString{ - TypesRequired: []string{}, - TypesMin: []string{"1"}, - TypesMax: []string{"1", "2", "3", "4", "5", "6"}, - TypesLen: []string{"1", "2"}, - TypesIn: []string{"d"}, - TypesNotIn: []string{"d", "b"}, - } - expectedMsgErrors = []string{ - "TypesRequired must not be empty", - "TypesMin must have at least 2 elements", - "TypesMax must have at most 5 elements", - "TypesLen must have exactly 3 elements", - "TypesIn elements must be one of 'a' 'b' 'c'", - "TypesNotIn elements must not be one of 'a' 'b' 'c'", - } - errs = SliceStringValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &SliceString{ - TypesRequired: []string{"Type1", "Type2"}, - TypesMin: []string{"1", "2"}, - TypesMax: []string{"1", "2", "3", "4"}, - TypesLen: []string{"1", "2", "3"}, - TypesIn: []string{"a", "b", "c", "b", "a"}, - TypesNotIn: []string{"d", "e", "f"}, - } - expectedMsgErrors = nil - errs = SliceStringValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("slice string tests ok") -} diff --git a/tests/endtoend/string.go b/tests/endtoend/string.go deleted file mode 100644 index e6c2167..0000000 --- a/tests/endtoend/string.go +++ /dev/null @@ -1,73 +0,0 @@ -package main - -import "log" - -type StringType struct { - FieldReq string `valid:"required"` - FieldEq string `valid:"eq=aabbcc"` - FieldEqIC string `valid:"eq_ignore_case=yes"` - FieldMinMax string `valid:"min=5,max=10"` - FieldLen string `valid:"len=8"` - FieldNeq string `valid:"neq=cba"` - FieldNeqIC string `valid:"neq_ignore_case=yes"` - FieldIn string `valid:"in=ab bc cd"` - FieldNotIn string `valid:"nin=xx yy zz"` - EmailReq string `valid:"required,email"` -} - -func stringTests() { - log.Println("starting string tests") - - var expectedMsgErrors []string - var errs []error - - // Test case 1: All failure scenarios - v := &StringType{ - FieldEq: "123", - FieldEqIC: "abc", - FieldMinMax: "1", - FieldLen: "abcde", - FieldNeq: "cba", - FieldNeqIC: "yes", - FieldIn: "abc", - FieldNotIn: "zz", - EmailReq: "invalid.email.format", // Invalid required email - } - expectedMsgErrors = []string{ - "FieldReq is required", - "FieldEq must be equal to 'aabbcc'", - "FieldEqIC must be equal to 'yes'", - "FieldMinMax length must be >= 5", - "FieldLen length must be 8", - "FieldNeq must not be equal to 'cba'", - "FieldNeqIC must not be equal to 'yes'", - "FieldIn must be one of 'ab' 'bc' 'cd'", - "FieldNotIn must not be one of 'xx' 'yy' 'zz'", - "EmailReq must be a valid email", - } - errs = StringTypeValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - // Test case 2: All valid input - v = &StringType{ - FieldReq: "123", - FieldEq: "aabbcc", - FieldEqIC: "yEs", - FieldMinMax: "12345678", - FieldLen: "abcdefgh", - FieldNeq: "ops", - FieldNeqIC: "No", - FieldIn: "bc", - FieldNotIn: "xy", - EmailReq: "user@example.com", // Valid required email - } - expectedMsgErrors = nil - errs = StringTypeValidate(v) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("string tests ok") -} diff --git a/tests/endtoend/validator__.go b/tests/endtoend/validator__.go index 89a7bbb..9f2f443 100755 --- a/tests/endtoend/validator__.go +++ b/tests/endtoend/validator__.go @@ -52,16 +52,6 @@ func AllTypes2Validate(obj *AllTypes2) []error { } return errs } -func ArrayStringValidate(obj *ArrayString) []error { - var errs []error - if !(types.SliceOnlyContains(obj.TypesIn[:], []string{"a", "b", "c"})) { - errs = append(errs, types.NewValidationError("TypesIn elements must be one of 'a' 'b' 'c'")) - } - if !(types.SliceNotContains(obj.TypesNotIn[:], []string{"a", "b", "c"})) { - errs = append(errs, types.NewValidationError("TypesNotIn elements must not be one of 'a' 'b' 'c'")) - } - return errs -} func BoolTypeValidate(obj *BoolType) []error { var errs []error if !(obj.FieldEqTrue == true) { @@ -152,506 +142,6 @@ func CmpNestedUint8FieldsValidate(obj *CmpNestedUint8Fields) []error { } return errs } -func MapStringValidate(obj *MapString) []error { - var errs []error - if !(len(obj.FieldRequired) != 0) { - errs = append(errs, types.NewValidationError("FieldRequired must not be empty")) - } - if !(len(obj.FieldMin) >= 2) { - errs = append(errs, types.NewValidationError("FieldMin must have at least 2 elements")) - } - if !(len(obj.FieldMax) <= 5) { - errs = append(errs, types.NewValidationError("FieldMax must have at most 5 elements")) - } - if !(len(obj.FieldLen) == 3) { - errs = append(errs, types.NewValidationError("FieldLen must have exactly 3 elements")) - } - if !(types.MapOnlyContains(obj.FieldIn, []string{"a", "b", "c"})) { - errs = append(errs, types.NewValidationError("FieldIn elements must be one of 'a' 'b' 'c'")) - } - if !(types.MapNotContains(obj.FieldNotIn, []string{"a", "b", "c"})) { - errs = append(errs, types.NewValidationError("FieldNotIn elements must not be one of 'a' 'b' 'c'")) - } - return errs -} -func MapUint8Validate(obj *MapUint8) []error { - var errs []error - if !(len(obj.FieldRequired) != 0) { - errs = append(errs, types.NewValidationError("FieldRequired must not be empty")) - } - if !(len(obj.FieldMin) >= 2) { - errs = append(errs, types.NewValidationError("FieldMin must have at least 2 elements")) - } - if !(len(obj.FieldMax) <= 5) { - errs = append(errs, types.NewValidationError("FieldMax must have at most 5 elements")) - } - if !(len(obj.FieldLen) == 3) { - errs = append(errs, types.NewValidationError("FieldLen must have exactly 3 elements")) - } - if !(types.MapOnlyContains(obj.FieldIn, []uint8{1, 2, 3})) { - errs = append(errs, types.NewValidationError("FieldIn elements must be one of '1' '2' '3'")) - } - if !(types.MapNotContains(obj.FieldNotIn, []uint8{1, 2, 3})) { - errs = append(errs, types.NewValidationError("FieldNotIn elements must not be one of '1' '2' '3'")) - } - return errs -} -func NumericTypeFloat32Validate(obj *NumericTypeFloat32) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5.9) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5.9")) - } - if !(obj.FieldNeq != 5.9) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5.9")) - } - if !(obj.FieldGt > 10.1) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10.1")) - } - if !(obj.FieldGte >= 10.1) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10.1")) - } - if !(obj.FieldLt < 9.9) { - errs = append(errs, types.NewValidationError("FieldLt must be < 9.9")) - } - if !(obj.FieldLte <= 9.9) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 9.9")) - } - if !(obj.FieldIn == 5.1 || obj.FieldIn == 6.2 || obj.FieldIn == 7.3) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5.1' '6.2' '7.3'")) - } - if !(obj.FieldNotIn != 8.5 && obj.FieldNotIn != 9.6 && obj.FieldNotIn != 10.7) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8.5' '9.6' '10.7'")) - } - return errs -} -func NumericTypeFloat64Validate(obj *NumericTypeFloat64) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5.9) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5.9")) - } - if !(obj.FieldNeq != 5.9) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5.9")) - } - if !(obj.FieldGt > 10.1) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10.1")) - } - if !(obj.FieldGte >= 10.1) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10.1")) - } - if !(obj.FieldLt < 9.9) { - errs = append(errs, types.NewValidationError("FieldLt must be < 9.9")) - } - if !(obj.FieldLte <= 9.9) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 9.9")) - } - if !(obj.FieldIn == 5.1 || obj.FieldIn == 6.2 || obj.FieldIn == 7.3) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5.1' '6.2' '7.3'")) - } - if !(obj.FieldNotIn != 8.5 && obj.FieldNotIn != 9.6 && obj.FieldNotIn != 10.7) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8.5' '9.6' '10.7'")) - } - return errs -} -func NumericTypeIntValidate(obj *NumericTypeInt) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func NumericTypeInt16Validate(obj *NumericTypeInt16) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func NumericTypeInt32Validate(obj *NumericTypeInt32) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func NumericTypeInt64Validate(obj *NumericTypeInt64) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func NumericTypeInt8Validate(obj *NumericTypeInt8) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func NumericTypeUintValidate(obj *NumericTypeUint) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func NumericTypeUint16Validate(obj *NumericTypeUint16) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func NumericTypeUint32Validate(obj *NumericTypeUint32) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func NumericTypeUint64Validate(obj *NumericTypeUint64) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func NumericTypeUint8Validate(obj *NumericTypeUint8) []error { - var errs []error - if !(obj.FieldReq != 0) { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == 5) { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 5")) - } - if !(obj.FieldNeq != 5) { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 5")) - } - if !(obj.FieldGt > 10) { - errs = append(errs, types.NewValidationError("FieldGt must be > 10")) - } - if !(obj.FieldGte >= 10) { - errs = append(errs, types.NewValidationError("FieldGte must be >= 10")) - } - if !(obj.FieldLt < 10) { - errs = append(errs, types.NewValidationError("FieldLt must be < 10")) - } - if !(obj.FieldLte <= 10) { - errs = append(errs, types.NewValidationError("FieldLte must be <= 10")) - } - if !(obj.FieldIn == 5 || obj.FieldIn == 6 || obj.FieldIn == 7) { - errs = append(errs, types.NewValidationError("FieldIn must be one of '5' '6' '7'")) - } - if !(obj.FieldNotIn != 8 && obj.FieldNotIn != 9 && obj.FieldNotIn != 10) { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of '8' '9' '10'")) - } - return errs -} -func SliceIntegerValidate(obj *SliceInteger) []error { - var errs []error - if !(len(obj.TypesRequired) != 0) { - errs = append(errs, types.NewValidationError("TypesRequired must not be empty")) - } - if !(len(obj.TypesMin) >= 2) { - errs = append(errs, types.NewValidationError("TypesMin must have at least 2 elements")) - } - if !(len(obj.TypesMax) <= 5) { - errs = append(errs, types.NewValidationError("TypesMax must have at most 5 elements")) - } - if !(len(obj.TypesLen) == 3) { - errs = append(errs, types.NewValidationError("TypesLen must have exactly 3 elements")) - } - if !(types.SliceOnlyContains(obj.TypesIn, []int{1, 2, 3})) { - errs = append(errs, types.NewValidationError("TypesIn elements must be one of '1' '2' '3'")) - } - if !(types.SliceNotContains(obj.TypesNotIn, []int{1, 2, 3})) { - errs = append(errs, types.NewValidationError("TypesNotIn elements must not be one of '1' '2' '3'")) - } - return errs -} -func SliceStringValidate(obj *SliceString) []error { - var errs []error - if !(len(obj.TypesRequired) != 0) { - errs = append(errs, types.NewValidationError("TypesRequired must not be empty")) - } - if !(len(obj.TypesMin) >= 2) { - errs = append(errs, types.NewValidationError("TypesMin must have at least 2 elements")) - } - if !(len(obj.TypesMax) <= 5) { - errs = append(errs, types.NewValidationError("TypesMax must have at most 5 elements")) - } - if !(len(obj.TypesLen) == 3) { - errs = append(errs, types.NewValidationError("TypesLen must have exactly 3 elements")) - } - if !(types.SliceOnlyContains(obj.TypesIn, []string{"a", "b", "c"})) { - errs = append(errs, types.NewValidationError("TypesIn elements must be one of 'a' 'b' 'c'")) - } - if !(types.SliceNotContains(obj.TypesNotIn, []string{"a", "b", "c"})) { - errs = append(errs, types.NewValidationError("TypesNotIn elements must not be one of 'a' 'b' 'c'")) - } - return errs -} -func StringTypeValidate(obj *StringType) []error { - var errs []error - if !(obj.FieldReq != "") { - errs = append(errs, types.NewValidationError("FieldReq is required")) - } - if !(obj.FieldEq == "aabbcc") { - errs = append(errs, types.NewValidationError("FieldEq must be equal to 'aabbcc'")) - } - if !(types.EqualFold(obj.FieldEqIC, "yes")) { - errs = append(errs, types.NewValidationError("FieldEqIC must be equal to 'yes'")) - } - if !(len(obj.FieldMinMax) >= 5) { - errs = append(errs, types.NewValidationError("FieldMinMax length must be >= 5")) - } - if !(len(obj.FieldMinMax) <= 10) { - errs = append(errs, types.NewValidationError("FieldMinMax length must be <= 10")) - } - if !(len(obj.FieldLen) == 8) { - errs = append(errs, types.NewValidationError("FieldLen length must be 8")) - } - if !(obj.FieldNeq != "cba") { - errs = append(errs, types.NewValidationError("FieldNeq must not be equal to 'cba'")) - } - if !(!types.EqualFold(obj.FieldNeqIC, "yes")) { - errs = append(errs, types.NewValidationError("FieldNeqIC must not be equal to 'yes'")) - } - if !(obj.FieldIn == "ab" || obj.FieldIn == "bc" || obj.FieldIn == "cd") { - errs = append(errs, types.NewValidationError("FieldIn must be one of 'ab' 'bc' 'cd'")) - } - if !(obj.FieldNotIn != "xx" && obj.FieldNotIn != "yy" && obj.FieldNotIn != "zz") { - errs = append(errs, types.NewValidationError("FieldNotIn must not be one of 'xx' 'yy' 'zz'")) - } - if !(obj.EmailReq != "") { - errs = append(errs, types.NewValidationError("EmailReq is required")) - } - if !(types.IsValidEmail(obj.EmailReq)) { - errs = append(errs, types.NewValidationError("EmailReq must be a valid email")) - } - return errs -} func UserValidate(obj *User) []error { var errs []error if !(obj.FirstName != "") { From 8b6f9237195f42b833bae0c09cb2cff481f9f96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Sandro=20Garz=C3=A3o?= Date: Sat, 8 Nov 2025 17:45:32 -0300 Subject: [PATCH 29/31] chore: remove duplicated tests --- tests/endtoend/main.go | 81 ------------------------------------------ 1 file changed, 81 deletions(-) diff --git a/tests/endtoend/main.go b/tests/endtoend/main.go index b9122c3..b906cce 100644 --- a/tests/endtoend/main.go +++ b/tests/endtoend/main.go @@ -33,8 +33,6 @@ type NoValidateInfo struct { func main() { log.Println("starting tests") - allTypes1Tests() - allTypes2Tests() structInPkgTests() nestedStructTests() cmpBetweenInnerFieldsTests() @@ -46,85 +44,6 @@ func main() { log.Println("finishing tests") } -func allTypes1Tests() { - var expectedMsgErrors []string - var errs []error - - v1 := &AllTypes1{} - expectedMsgErrors = []string{ - "FirstName is required", - "LastName is required", - "Age is required", - } - errs = AllTypes1Validate(v1) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - v2 := &AllTypes1{ - FirstName: "First", - LastName: "Last", - Age: 18, - } - expectedMsgErrors = nil - errs = AllTypes1Validate(v2) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("all_types1 tests ok") -} - -func allTypes2Tests() { - var expectedMsgErrors []string - var errs []error - - v1 := &AllTypes2{ - FirstName: "", - LastName: "", - Age: 135, - UserName: "abc", - } - expectedMsgErrors = []string{ - "FirstName is required", - "LastName is required", - "Age must be <= 130", - "UserName length must be >= 5", - } - errs = AllTypes2Validate(v1) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - v2 := &AllTypes2{ - FirstName: "First", - LastName: "Last", - Age: 49, - UserName: "mylongusername", - } - expectedMsgErrors = []string{ - "UserName length must be <= 10", - } - errs = AllTypes2Validate(v2) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - v3 := &AllTypes2{ - FirstName: "First", - LastName: "Last", - Age: 49, - UserName: "myusername", - } - expectedMsgErrors = nil - errs = AllTypes2Validate(v3) - if !expectedMsgErrorsOk(errs, expectedMsgErrors) { - log.Fatalf("error = %v, wantErr %v", errs, expectedMsgErrors) - } - - log.Println("all_types2 tests ok") -} - func structInPkgTests() { var expectedMsgErrors []string var errs []error From 4b13775c26b499132c978d218c4a122a3fcab4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Sandro=20Garz=C3=A3o?= Date: Mon, 10 Nov 2025 21:12:05 -0300 Subject: [PATCH 30/31] chore: update testgen readme --- testgen/README.md | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/testgen/README.md b/testgen/README.md index b101ed1..d45a598 100644 --- a/testgen/README.md +++ b/testgen/README.md @@ -70,28 +70,25 @@ At this time, ValidGen already has two generators: But these generators do not have a common configuration, do not implement all tests for all cases, and keeping the distinct configuration files in sync is painful. -Beyond that, some new generators could be created: -- Unit tests to validate operations -- Unit tests to validate operation x type -- Unit tests to validate the "buildValidationCode" function -- Unit tests to validate the "condition table" -- Parser tests -- Almost all existing end-to-end tests could be generated -- Examples (in _examples/) could be generated - -And, for all cases, valid scenarios and invalid scenarios must be generated. - ## What TestGen does -TestGen generates the following tests: -- Benchmark tests between ValidGen and GoValidator -- End-to-end tests with all possible use cases (all validations vs all types vs valid and invalid inputs) -- Unit tests to validate operations -- Unit tests to validate operation vs type -- Unit tests to validate the "buildValidationCode" function -- Unit tests to validate "condition table" result -- Parser tests (parser_tests.go) -- Examples (in _examples/) +TestGen generates the following tests (without field operations): +- [x] Benchmark tests between ValidGen and GoValidator +- [x] End-to-end tests with all possible use cases (all validations vs all types vs valid and invalid inputs) +- [x] Unit tests to validate the "buildValidationCode" function + +High priority generators: +- [ ] Unit tests to validate the "condition table" (get_test_elements_*_test.go) +- [ ] Benchmark tests between ValidGen and GoValidator with field operations +- [ ] End-to-end tests with all possible use cases (all validations vs all types vs valid and invalid inputs) with field operations +- [ ] Unit tests to validate the "buildValidationCode" function with field operations + +Low priority generators (already exist, but they could be generated): +- [ ] Unit tests to validate operations (func TestOperationsIsValid) +- [ ] Unit tests to validate operation vs type (func TestOperationsIsValidByType) +- [ ] Unit tests to validate if is field operation (func TestOperationsIsFieldOperation) +- [ ] Unit tests to validate arguments count by operation (func TestOperationsArgsCount) +- [ ] Examples (in _examples/) could be generated In some cases, valid scenarios and invalid scenarios must be generated. From d7c4ae75c8a32a40c7d22692eb3d1889ef22ffcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Sandro=20Garz=C3=A3o?= Date: Tue, 11 Nov 2025 10:15:44 -0300 Subject: [PATCH 31/31] doc: update testgen readme --- testgen/README.md | 94 +++++++++++++++++++++-------------------------- 1 file changed, 42 insertions(+), 52 deletions(-) diff --git a/testgen/README.md b/testgen/README.md index d45a598..eb85740 100644 --- a/testgen/README.md +++ b/testgen/README.md @@ -1,14 +1,14 @@ # TestGen -TestGen is the tool responsible for generating tests related to ValidGen validators and supported types. -These generated tests included unit tests, end-to-end tests, and benchmark tests. -In the case of benchmark tests, it means comparing ValidGen and GoValidator. +TestGen is a tool responsible for generating comprehensive test suites for ValidGen validators and supported types. +These generated tests include unit tests, end-to-end tests, and benchmark tests. +The benchmark tests compare ValidGen and GoValidator performance. ## Why a new tool? -First of all, it is necessary to answer the question: why a new tool to generate tests? +First, let's address the question: why create a dedicated tool for test generation? -Currently, ValidGen has 21 possible validations with support for some types: +ValidGen currently supports 21 validations across multiple data types: | Validation | Basic types | Slice | Array | Map | | - | - | - | - | - | @@ -34,41 +34,42 @@ Currently, ValidGen has 21 possible validations with support for some types: | ltefield | INT | | | | | ltfield | INT | | | | -In this table, STRING represents the string Go type, and BOOL represents the bool Go type. -But INT represents the ten integer Go types: int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64. -In the same way, FLOAT represents the 2 float go types: float32, float64. -In the same way, slice STRING is just []string, but slice INT is split between all integer Go types. -For array and map, the rule is the same. -And, an important modifier is "*" (pointer) because the code generated is different with or without a pointer. - -For each possible combination (validation x type) is necessary to have the following tests: -- Unit test in the analyzer phase -- Unit test in the code generator phase -- Benchmark test between ValidGen and GoValidator -- End-to-end test +In this table: +- **STRING** represents the `string` Go type +- **BOOL** represents the `bool` Go type +- **INT** represents all ten integer Go types: `int`, `int8`, `int16`, `int32`, `int64`, `uint`, `uint8`, `uint16`, `uint32`, `uint64` +- **FLOAT** represents both float Go types: `float32`, `float64` + +For slices, arrays, and maps, the same type expansion applies. For example, slice STRING is `[]string`, while slice INT expands to all integer Go types. -As it is necessary to test all valid and invalid scenarios, it is necessary to test all validations against all types. -At this time, it means: -- Go types (14) -- Validations (21) -- Test types (4) -- Types with and without a pointer (2) -- Tests with valid and invalid inputs (2) +Additionally, the pointer modifier (`*`) is significant because ValidGen generates different code for pointer and non-pointer types. + +For each possible combination (validation × type), the following tests are required: +- Unit test for the analyzer phase +- Unit test for the code generator phase +- Benchmark test comparing ValidGen and GoValidator +- End-to-end test -14 x 21 x 4 x 2 x 2 = 4.704 distinct test cases :-) +Since we need to test both valid and invalid scenarios, all validations must be tested against all types. +Currently, this means: +- Go types: 14 +- Validations: 21 +- Test types: 4 +- Pointer variants: 2 (with/without pointer) +- Input scenarios: 2 (valid/invalid) -With all the tests that need to be created (valid inputs, invalid inputs) for unit tests, benchmark, and end-to-end tests, creating the tests "by hand" is a tedious and error-prone task. +**14 × 21 × 4 × 2 × 2 = 4,704 distinct test cases** -Some of these necessary unit tests were created "by hand", but it is a pain to keep the code in sync when supporting new operations and types. +Creating and maintaining these thousands of tests manually is tedious, error-prone, and impractical. Early attempts to write these tests by hand proved difficult to maintain when adding new operations and types. -At this time, ValidGen already has two generators: -- To generate benchmark tests between ValidGen and GoValidator -- To generate end-to-end tests - - to validate ValidGen with integer types - - to validate ValidGen with float types - - to validate all possible use cases in ValidGen (all validations x all types) +Previously, ValidGen had two separate test generators: +- Benchmark tests comparing ValidGen and GoValidator +- End-to-end tests for: + - Integer type validations + - Float type validations + - All possible use cases (all validations × all types) -But these generators do not have a common configuration, do not implement all tests for all cases, and keeping the distinct configuration files in sync is painful. +However, these generators lacked a common configuration, didn't implement all tests for all cases, and keeping the separate configuration files in sync was difficult. ## What TestGen does @@ -83,34 +84,23 @@ High priority generators: - [ ] End-to-end tests with all possible use cases (all validations vs all types vs valid and invalid inputs) with field operations - [ ] Unit tests to validate the "buildValidationCode" function with field operations -Low priority generators (already exist, but they could be generated): +Low priority generators (already exist, but could be automated): - [ ] Unit tests to validate operations (func TestOperationsIsValid) - [ ] Unit tests to validate operation vs type (func TestOperationsIsValidByType) -- [ ] Unit tests to validate if is field operation (func TestOperationsIsFieldOperation) -- [ ] Unit tests to validate arguments count by operation (func TestOperationsArgsCount) +- [ ] Unit tests to validate field operations (func TestOperationsIsFieldOperation) +- [ ] Unit tests to validate argument count by operation (func TestOperationsArgsCount) - [ ] Examples (in _examples/) could be generated -In some cases, valid scenarios and invalid scenarios must be generated. +Where applicable, TestGen generates both valid and invalid test scenarios. -## How TestGen works +## Usage -To be possible to generate all these tests, TestGen must have a configuration with: -- All valid operations -- All valid go types -- All valid operation x type -- Valid input cases for each operation x type -- Invalid input cases for each operation x type -- Equivalent GoValidator tag - -## Steps to generate the tests - -The steps to generate the tests are: +To generate the tests: ```bash -# Enter in the project root folder +# Navigate to the project root folder cd validgen # Run testgen make testgen ``` -