diff --git a/xsdgen/example_test.go b/xsdgen/example_test.go index 3e3e004..c671f1b 100644 --- a/xsdgen/example_test.go +++ b/xsdgen/example_test.go @@ -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 } diff --git a/xsdgen/xsdgen.go b/xsdgen/xsdgen.go index 0604c4d..011fa92 100644 --- a/xsdgen/xsdgen.go +++ b/xsdgen/xsdgen.go @@ -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 { @@ -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