Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
eaa2abf
feat: type struct to deal with complex types (array, slice)
alexgarzao Sep 27, 2025
c80a584
chore: use FieldType instead of string
alexgarzao Sep 27, 2025
0d9b9b9
refact: IsGoType is a FieldType method now
alexgarzao Sep 27, 2025
97671da
chore: register a possible refactor
alexgarzao Sep 28, 2025
dc85a43
chore: removes unused tests
alexgarzao Sep 29, 2025
1b54cad
chore: forgot to update docs and tests related to bool type
alexgarzao Sep 29, 2025
7ee2bd2
Merge branch 'main' into 59-support-all-numeric-types
alexgarzao Oct 1, 2025
9eddafb
chore: use the correct template engine (text)
alexgarzao Oct 1, 2025
36acdd0
tests: generator to check for all integer types
alexgarzao Oct 1, 2025
c90d351
feat: normalize the specific type to a class (int, float, string, bool)
alexgarzao Oct 1, 2025
c0a76e6
feat: normalize the specific type to a class (int, float, string, bool)
alexgarzao Oct 1, 2025
dd1fd7b
tests: run generator to check for all integer types
alexgarzao Oct 1, 2025
8ba7c7b
feat: parser list of integers
alexgarzao Oct 1, 2025
7d013de
feat: deal with generic type in the analyzer
alexgarzao Oct 1, 2025
64343e5
feat: deal with generic int types during code generation
alexgarzao Oct 1, 2025
e6b991a
doc: update readme with new validations
alexgarzao Oct 1, 2025
630af30
fix: avoid panic with invalid parameter
alexgarzao Oct 2, 2025
1878544
fix: only known types can use validations
alexgarzao Oct 2, 2025
be64ec8
feat: new operations related to slice and array with integers
alexgarzao Oct 2, 2025
00fe1f8
test: helper funcs to support tests with normalized tests
alexgarzao Oct 2, 2025
cda5ad1
test: parser are correct with slice and arrays of string and int
alexgarzao Oct 2, 2025
9d906a4
feat: new array and slices operations with string and integers
alexgarzao Oct 2, 2025
9182a1a
chore: remove useless func
alexgarzao Oct 2, 2025
11aefcd
refact: move test to helper file
alexgarzao Oct 2, 2025
873b63f
refact: helper prefix in func related to tests
alexgarzao Oct 3, 2025
0d71163
chore: remove all about partial float support
alexgarzao Oct 3, 2025
42a86c3
feat: missed []int operations
alexgarzao Oct 3, 2025
489c591
chore: remove useless TODO
alexgarzao Oct 3, 2025
63a711d
FIX: avoid normalized types with an invalid go type
alexgarzao Oct 3, 2025
7cfd625
chore: generated numeric tests more idiomatic
alexgarzao Oct 3, 2025
d3b9919
tests: invalid array type, invalid array size, invalid type
alexgarzao Oct 3, 2025
612ded6
fix: avoid log fatal
alexgarzao Oct 3, 2025
76f36f5
refact: avoid duplication in helpers func
alexgarzao Oct 3, 2025
6d66ed8
chore: change from strings.Title to cases.Title
alexgarzao Oct 3, 2025
30b1c3f
fix: format %s with struct
alexgarzao Oct 3, 2025
c296e64
refact: func names using go conventions
alexgarzao Oct 3, 2025
615e71d
Merge branch 'main' into 82-func-names-using-go-conventions
alexgarzao Oct 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/analyzer/parser_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/opencodeco/validgen/types"
)

func Test_ValidParserValidation(t *testing.T) {
func TestValidParserValidation(t *testing.T) {
tests := []struct {
name string
validation string
Expand Down Expand Up @@ -148,7 +148,7 @@ func Test_ValidParserValidation(t *testing.T) {
}
}

func Test_ParserInvalidValidation(t *testing.T) {
func TestParserInvalidValidation(t *testing.T) {
tests := []struct {
name string
validation string
Expand Down
2 changes: 1 addition & 1 deletion internal/common/normalized_base_type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package common

import "testing"

func TestNormalizedBaseType_String(t *testing.T) {
func TestNormalizedBaseTypeString(t *testing.T) {
tests := []struct {
name string
n NormalizedBaseType
Expand Down
4 changes: 2 additions & 2 deletions internal/common/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"
)

func TestFieldType_ToString(t *testing.T) {
func TestFieldTypeToString(t *testing.T) {
type fields struct {
ComposedType string
BaseType string
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestFieldType_ToString(t *testing.T) {
}
}

func TestFieldType_IsGoType(t *testing.T) {
func TestFieldTypeIsGoType(t *testing.T) {
type args struct {
fieldType FieldType
}
Expand Down
2 changes: 1 addition & 1 deletion tests/endtoend/array_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type ArrayString struct {
TypesNotIn [8]string `valid:"nin=a b c"`
}

func array_string_tests() {
func arrayStringTests() {
log.Println("starting array string tests")

var expectedMsgErrors []string
Expand Down
2 changes: 1 addition & 1 deletion tests/endtoend/bool.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type BoolType struct {
FieldNeqFieldEqTrue bool `valid:"neqfield=FieldEqTrue"`
}

func bool_tests() {
func boolTests() {
log.Println("starting bool tests")

var expectedMsgErrors []string
Expand Down
14 changes: 7 additions & 7 deletions tests/endtoend/cmp_between_inner_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"log"
)

func cmp_between_inner_fields_tests() {
func cmpBetweenInnerFieldsTests() {
log.Println("starting between inner fields tests")

cmp_between_inner_string_fields_tests()
cmp_between_inner_uint8_fields_tests()
cmp_between_inner_bool_fields_tests()
cmpBetweenInnerStringFieldsTests()
cmpBetweenInnerUint8FieldsTests()
cmpBetweenInnerBoolFieldsTests()

log.Println("cmp between inner fields tests ok")
}
Expand All @@ -20,7 +20,7 @@ type CmpInnerStringFields struct {
Field3neq1 string `valid:"neqfield=Field1"`
}

func cmp_between_inner_string_fields_tests() {
func cmpBetweenInnerStringFieldsTests() {
log.Println("starting between inner string fields tests")

var expectedMsgErrors []string
Expand Down Expand Up @@ -67,7 +67,7 @@ type CmpInnerUint8Fields struct {
Field8lt4 uint8 `valid:"ltfield=Field4"`
}

func cmp_between_inner_uint8_fields_tests() {
func cmpBetweenInnerUint8FieldsTests() {
log.Println("starting between inner uint8 fields tests")

var expectedMsgErrors []string
Expand Down Expand Up @@ -123,7 +123,7 @@ type CmpInnerBoolFields struct {
Field3neq1 bool `valid:"neqfield=Field1"`
}

func cmp_between_inner_bool_fields_tests() {
func cmpBetweenInnerBoolFieldsTests() {
log.Println("starting between inner bool fields tests")

var expectedMsgErrors []string
Expand Down
10 changes: 5 additions & 5 deletions tests/endtoend/cmp_between_nested_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"log"
)

func cmp_between_nested_fields_tests() {
func cmpBetweenNestedFieldsTests() {
log.Println("starting between nested fields tests")

cmp_between_nested_string_fields_tests()
cmp_between_nested_uint8_fields_tests()
cmpBetweenNestedStringFieldsTests()
cmpBetweenNestedUint8FieldsTests()

log.Println("cmp between nested fields tests ok")
}
Expand All @@ -23,7 +23,7 @@ type NestedStringFields struct {
Field1 string
}

func cmp_between_nested_string_fields_tests() {
func cmpBetweenNestedStringFieldsTests() {
log.Println("starting between nested string fields tests")

var expectedMsgErrors []string
Expand Down Expand Up @@ -78,7 +78,7 @@ type NestedUint8Fields struct {
Field2 uint8
}

func cmp_between_nested_uint8_fields_tests() {
func cmpBetweenNestedUint8FieldsTests() {
log.Println("starting between nested uint8 fields tests")

var expectedMsgErrors []string
Expand Down
6 changes: 3 additions & 3 deletions tests/endtoend/generate_tests/numeric.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ package main

import "log"

func numeric_tests() {
func numericTests() {
log.Println("starting numeric tests")

{{range .FieldTypes}}numeric_{{.}}_tests()
{{range .FieldTypes}}numeric{{. | title }}Tests()
{{end}}
log.Println("numeric tests ok")
}
Expand All @@ -25,7 +25,7 @@ type NumericType{{. | title }} struct {
FieldNotIn {{.}} `valid:"nin=8 9 10"`
}

func numeric_{{.}}_tests() {
func numeric{{. | title }}Tests() {
log.Println("starting numeric {{.}} tests")

var expectedMsgErrors []string
Expand Down
34 changes: 17 additions & 17 deletions tests/endtoend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,25 @@ type NoValidateInfo struct {
func main() {
log.Println("starting tests")

all_types1_tests()
all_types2_tests()
struct_in_pkg_tests()
string_tests()
nested_struct_tests()
slice_string_tests()
slice_integer_tests()
array_string_tests()
cmp_between_inner_fields_tests()
cmp_between_nested_fields_tests()
bool_tests()
map_string_tests()
map_uint8_tests()
numeric_tests()
allTypes1Tests()
allTypes2Tests()
structInPkgTests()
stringTests()
nestedStructTests()
sliceStringTests()
sliceIntegerTests()
arrayStringTests()
cmpBetweenInnerFieldsTests()
cmpBetweenNestedFieldsTests()
boolTests()
mapStringTests()
mapUint8Tests()
numericTests()

log.Println("finishing tests")
}

func all_types1_tests() {
func allTypes1Tests() {
var expectedMsgErrors []string
var errs []error

Expand Down Expand Up @@ -78,7 +78,7 @@ func all_types1_tests() {
log.Println("all_types1 tests ok")
}

func all_types2_tests() {
func allTypes2Tests() {
var expectedMsgErrors []string
var errs []error

Expand Down Expand Up @@ -128,7 +128,7 @@ func all_types2_tests() {
log.Println("all_types2 tests ok")
}

func struct_in_pkg_tests() {
func structInPkgTests() {
var expectedMsgErrors []string
var errs []error

Expand Down
2 changes: 1 addition & 1 deletion tests/endtoend/map_numeric.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type MapUint8 struct {
FieldNotIn map[uint8]string `valid:"nin=1 2 3"`
}

func map_uint8_tests() {
func mapUint8Tests() {
log.Println("starting map uint8 tests")

var expectedMsgErrors []string
Expand Down
2 changes: 1 addition & 1 deletion tests/endtoend/map_string.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type MapString struct {
FieldNotIn map[string]string `valid:"nin=a b c"`
}

func map_string_tests() {
func mapStringTests() {
log.Println("starting map string tests")

var expectedMsgErrors []string
Expand Down
10 changes: 5 additions & 5 deletions tests/endtoend/nested_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ type UserWithStructInPkg struct {
Address structsinpkg.Address `valid:"required"`
}

func nested_struct_tests() {
func nestedStructTests() {
log.Println("starting nested struct tests")

nested_struct_tests1()
nested_struct_tests2()
nestedStructTests1()
nestedStructTests2()

log.Println("nested struct tests ok")
}

func nested_struct_tests1() {
func nestedStructTests1() {
log.Println("starting nested struct tests 1")

var expectedMsgErrors []string
Expand Down Expand Up @@ -73,7 +73,7 @@ func nested_struct_tests1() {
log.Println("nested struct tests 1 ok")
}

func nested_struct_tests2() {
func nestedStructTests2() {
log.Println("starting nested struct tests 2")

var expectedMsgErrors []string
Expand Down
Loading