# The Enumeration constraint failed

Source: https://xmlvalid.com/errors/enumeration-constraint-failed

> A value is not one of the fixed values the schema allows.

The message, as .NET reports it: `The 'status' element is invalid - The value 'closed' is invalid according to its datatype 'Status' - The Enumeration constraint failed.`

## Why it happens

- A value missing from the list: a new status, a code from a newer code list.
- A different letter case or surrounding spaces.

## How to fix it

- Use one of the values the type lists; .NET doesn't name them, so look the type (`Status` here) up in the schema.
- .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 'enumeration'] The value is not an element of the set](https://xmlvalid.com/errors/facet-enumeration): `Element 'status': [facet 'enumeration'] The value 'closed' is not an element of the set {'open', 'paid'}.`

## Example that fails

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
  <status>closed</status>
</order>
```

## Fixed

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
  <status>paid</status>
</order>
```
