PARSER ERROR CODES

cvc-minLength-valid / cvc-maxLength-valid: length bounds

XSDHub · Tested 5 November 2026 · How we test guides

These related facets place lower and upper bounds on the length measured by a simple datatype. They belong in one diagnostic guide because the repair starts with the same question: what does this type count, and at which processing stage?

What the message literally means

The minimum example requires at least three characters: AB has length two and ABC has length three. The maximum example permits at most five characters: ABCDEF has length six and ABCDE has length five. Each pair has its own complete schema so neither boundary can mask the other during reproduction.

Three common causes to check first

  1. The exporter truncates a field, omits part of an identifier or sends a placeholder shorter than the required minimum. Empty tags count as empty values for these string specimens.
  2. The value contains extra whitespace or added formatting. The base datatype’s whitespace behavior decides whether those characters survive before the length facet runs.
  3. The application counts the wrong units. String length, list item count and binary length are different measures; byte counts and UI character counters need not match the schema datatype.

Repair and retest

Find the restriction base and determine the units used by its length facets. Check inherited bounds as well as the immediate declaration. Test the exact boundary, one unit below and one above using the receiving validator. Repair the original field or contract mapping rather than padding an identifier with arbitrary characters or silently dropping meaningful content.

When this is a namespace problem

Neither tested boundary failure is repaired by adding a namespace: the code element already matches its declaration. A namespace issue is plausible only when the wrong declaration or schema version supplies unexpected bounds. Verify the effective type before assuming that the validator’s reported length is a browser character-counting bug.

Reading equivalent reports

The corrected short strings are demonstrations of boundary behavior, not instructions to truncate production data. For identifiers, truncation can create collisions; for names, padding can corrupt meaning. Keep the original data and resolve the mapping or schema agreement that explains the bound. The two transcripts below preserve each engine’s own length wording.

Complete tested XML and XSD pairs

Open either variant in the workbench, then choose Validate XML. Loading an example does not run validation or send documents; server checks require the existing permission checkbox.

These transcripts were captured on 5 November 2026 from the exact files shown below. Download all measured results and SHA-256 hashes.

Minimum length / cvc-minLength-valid

Broken XML

<code>AB</code>
Broken complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="code">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:minLength value="3"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
</xs:schema>

Download XML · Download XSD

Open broken pair →

Corrected XML

<code>ABC</code>
Corrected complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="code">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:minLength value="3"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
</xs:schema>

Download XML · Download XSD

Open corrected pair →

Same specimen across engines

EngineBroken: actual reportCorrected
Apache Xerces-J 2.12.2
Validation
cvc-minLength-valid: Value 'AB' with length = '2' is not facet-valid with respect to minLength '3' for type '#AnonType_code'.
cvc-type.3.1.3: The value 'AB' of element 'code' is not valid.
PASS
.NET 8.0.33 · System.Xml.Schema
Validation
The 'code' element is invalid - The value 'AB' is invalid according to its datatype 'String' - The actual length is less than the MinLength value.
PASS (no warnings)
XSDHub libxml2/WASM 0.7.2
Validation
Element 'code': [facet 'minLength'] The value has a length of '2'; this underruns the allowed minimum length of '3'.
PASS
XSDHub xmlschema 4.3.1 · XSD 1.0
Validation
value length cannot be lesser than 3
PASS
SaxonEE comparison: cvc-minLength-valid describes the corresponding XSD constraint. No Saxon-EE run or wording is claimed; an EE licence is unavailable in this test environment. Saxon-HE does not provide XSD validation.Not run

Maximum length / cvc-maxLength-valid

Broken XML

<code>ABCDEF</code>
Broken complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="code">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:maxLength value="5"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
</xs:schema>

Download XML · Download XSD

Open broken pair →

Corrected XML

<code>ABCDE</code>
Corrected complete XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="code">
    <xs:simpleType>
      <xs:restriction base="xs:string">
        <xs:maxLength value="5"/>
      </xs:restriction>
    </xs:simpleType>
  </xs:element>
</xs:schema>

Download XML · Download XSD

Open corrected pair →

Same specimen across engines

EngineBroken: actual reportCorrected
Apache Xerces-J 2.12.2
Validation
cvc-maxLength-valid: Value 'ABCDEF' with length = '6' is not facet-valid with respect to maxLength '5' for type '#AnonType_code'.
cvc-type.3.1.3: The value 'ABCDEF' of element 'code' is not valid.
PASS
.NET 8.0.33 · System.Xml.Schema
Validation
The 'code' element is invalid - The value 'ABCDEF' is invalid according to its datatype 'String' - The actual length is greater than the MaxLength value.
PASS (no warnings)
XSDHub libxml2/WASM 0.7.2
Validation
Element 'code': [facet 'maxLength'] The value has a length of '6'; this exceeds the allowed maximum length of '5'.
PASS
XSDHub xmlschema 4.3.1 · XSD 1.0
Validation
value length cannot be greater than 5
PASS
SaxonEE comparison: cvc-maxLength-valid describes the corresponding XSD constraint. No Saxon-EE run or wording is claimed; an EE licence is unavailable in this test environment. Saxon-HE does not provide XSD validation.Not run

Saxon comparison and test scope

Saxonica documents XSD processing as an Enterprise Edition feature. The Saxon rows map the named constraint, rather than presenting an invented message. The four measured rows are Xerces, .NET, the shipped workbench engine and XSDHub’s second engine.

The corrected results apply to these self-contained XSD 1.0 specimens. They do not establish business-rule acceptance for a different document or schema version.

Continue the diagnosis

All parser error codes · XML and XSD validator

Primary references