Skip to content

fix length restriction #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion xsdgen/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func ExamplePackageName() {
//
// package postal
//
// // May be no more than 10 items long
// // Must be equal 10 items long
// type Zipcode string
}

Expand Down
8 changes: 6 additions & 2 deletions xsdgen/xsdgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,11 @@ func (cfg *Config) expandComplexTypes(types []xsd.Type) []xsd.Type {
// type that the user wants included in the Go source. In affect, what we
// want to do is take the linked list:
//
// t1 -> t2 -> t3 -> builtin
// t1 -> t2 -> t3 -> builtin
//
// And produce a set of tuples:
//
// t1 -> builtin, t2 -> builtin, t3 -> builtin
// t1 -> builtin, t2 -> builtin, t3 -> builtin
//
// This is a heuristic that tends to generate better-looking Go code.
func (cfg *Config) flatten(types map[xml.Name]xsd.Type) []xsd.Type {
Expand Down Expand Up @@ -463,6 +463,10 @@ func (cfg *Config) flatten1(t xsd.Type, push func(xsd.Type), depth int) xsd.Type
t.Doc = "Must be at least " + strconv.Itoa(t.Restriction.MinLength) + " items long"
return t
}
if t.Restriction.Length != 0 {
t.Doc = "Must be equal " + strconv.Itoa(t.Restriction.Length) + " items long"
return t
}
return t.Base
case *xsd.ComplexType:
// We can "unpack" a struct if it is extending a simple
Expand Down