goetas-webservices / xsd2php

Convert XSD into PHP classes and JMS serializer definitions
MIT License
238 stars 93 forks source link

Validation metadata setting max count = 2 to elements with no maxOccurs. #135

Open fell-lucas opened 3 years ago

fell-lucas commented 3 years ago

Hello, I have the following structure in my XSD schema:

<xs:element name="Docentes">
  <xs:complexType>
    <xs:sequence minOccurs="1" maxOccurs="unbounded">
      <xs:element name="Docente">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="Nome" type="TNome"/>
            <xs:element name="Titulacao" type="TTitulacao"/>
          </xs:sequence>
         </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>

When generating validation metadata, this is the related yml file generated:

docentes:
            -
                NotNull:
                    groups:
                        - xsd_rules
            -
                Count:
                    min: 1
                    max: 2
                    groups:
                        - xsd_rules
            -
                Valid: null

Even though the sequence inside the parent element has an "unbounded" maxOccurs, the validator returns the following violation: (in this case, there are 4 elements, and it's complaining because it thinks it should only contain 2 max.)

image

Removing "max" from count in the generated yaml file fixes the issue.

Count:
  min: 1
  groups:
    - xsd_rules