XSD validation error
The value is shorter than minLength
The value is shorter than the simple type's minLength facet permits, often because trimming differs between producer and schema.
Element 'nickname': [facet 'minLength'] The value has a length of '2'; this underruns the allowed minimum length of '3'. (line 4)What it means
minLength constrains the length of a datatype's value after its whitespace rules have been applied. For xs:string-derived values, length is counted in Unicode characters rather than UTF-8 bytes.
The diagnostic gives both the observed and allowed lengths. That makes this a contract mismatch, not a parse problem: the XML is complete and the value is simply too short.
What usually causes it
- A placeholder or abbreviation is shorter than the production contract allows.
- Whitespace normalization collapses or removes characters before the length check.
- The schema was tightened without updating existing producers or stored records.
- Application code counted bytes or UTF-16 code units while the schema processor counted characters.
How to fix it
- Supply a value whose post-normalization length meets the facet.
- Validate after applying the same trimming and normalization the serializer uses.
- Lower minLength only when the business rule really changed; do not pad values with meaningless spaces.
The same error elsewhere
libxml2 words these plainly. Xerces numbers them, and those cvc- codes are what most people end up searching for.
Xerces (Java)
cvc-minLength-valid: Value 'Al' with length = '2' is not facet-valid with respect to minLength '3'..NET System.Xml
The MinLength constraint failed.
Before and after
Both documents below are well-formed XML — that is the point. The test suite re-checks them against the real validator on every build: the first is confirmed to produce the exact message above, the second to validate cleanly.
<?xml version="1.0" encoding="UTF-8"?>
<order id="A-1">
<customer>Ada</customer>
<nickname>Al</nickname>
<issued>2026-01-31</issued>
<state>open</state>
<line>
<code>AB-1234</code>
<qty>2</qty>
</line>
</order>
<?xml version="1.0" encoding="UTF-8"?>
<order id="A-1">
<customer>Ada</customer>
<issued>2026-01-31</issued>
<state>open</state>
<line>
<code>AB-1234</code>
<qty>2</qty>
</line>
</order>
The schema both are checked against
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="status">
<xs:restriction base="xs:string">
<xs:enumeration value="open"/>
<xs:enumeration value="closed"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="sku">
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z]{2}-\d{4}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="shortLabel">
<xs:restriction base="xs:string">
<xs:minLength value="3"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="order">
<xs:complexType>
<xs:sequence>
<xs:element name="customer" type="xs:string"/>
<xs:element name="middleName" type="xs:string" minOccurs="0"/>
<xs:element name="nickname" type="shortLabel" minOccurs="0"/>
<xs:element name="issued" type="xs:date"/>
<xs:element name="state" type="status"/>
<xs:element name="line" minOccurs="1" maxOccurs="2">
<xs:complexType>
<xs:sequence>
<xs:element name="code" type="sku"/>
<xs:element name="qty" type="xs:positiveInteger"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>
Where this bites most
Other schema errors
- The attribute is required but missing
- The attribute is not allowed
- This element is not expected
- Missing child element(s)
- Not a valid value of the atomic type
- The value is not an element of the set
- The value is not accepted by the pattern
- No matching global declaration for the validation root
- The element is not nillable
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.