# [facet 'pattern'] The value is not accepted by the pattern

Source: https://xmlvalid.com/errors/facet-pattern

> A value that does not match the regular expression the schema requires.

Example message: `Element 'code': [facet 'pattern'] The value 'ab-12' is not accepted by the pattern '[A-Z]{3}-[0-9]{4}'.`

## Why it happens

- Wrong case, length or separators: identifiers, postal codes, IBANs, phone numbers.
- Leading or trailing spaces. XSD patterns match the whole value, as if wrapped in `^…$`.

## How to fix it

- The message shows the pattern. Format the value to match all of it; for long patterns, test the value against it in a regular-expression tool, keeping in mind that XSD has no `^`, `$` or lazy quantifiers.

## Example that fails

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
  <code>ab-12</code>
</order>
```

## Fixed

```xml
<order currency="EUR">
  <id>A-1</id>
  <qty>1</qty>
  <code>ABC-0012</code>
</order>
```
