# The actual length is greater than the MaxLength value

Source: https://xmlvalid.com/errors/actual-length-is-greater-than-the-maxlength-value

> A value is longer than its type allows.

The message, as .NET reports it: `The 'note' element is invalid - The value 'far too long text' is invalid according to its datatype 'Short' - The actual length is greater than the MaxLength value.`

## Why it happens

- Text longer than the format allows: a name, an address line, a free-text note.
- Whitespace or a line break inside the element, which counts towards the length.

## How to fix it

- Shorten the value to the type's `xs:maxLength`. *The actual length is less than the MinLength value* is the same check for a minimum.
- .NET throws an `XmlSchemaValidationException` at the first schema error unless `XmlReaderSettings.ValidationEventHandler` is set, which then receives every one with its line and position. A well-formedness error is an `XmlException` and ends reading whatever the settings.

## The same problem in xmlvalid

libxml2, which xmlvalid validates with, reports it as [[facet 'maxLength'] The value exceeds the allowed length](https://xmlvalid.com/errors/facet-length): `Element 'note': [facet 'maxLength'] The value has a length of '17'; this exceeds the allowed maximum length of '10'.`

## Example that fails

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
  <note>far too long text</note>
</order>
```

## Fixed

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
  <note>short</note>
</order>
```
