# JSON Schema validation fails: format 'email' rejects valid emails with plus signs or international characters

- **ID:** `data/json-schema-format-email-validation-failure`
- **Domain:** data
- **Category:** validation_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

JSON Schema's built-in 'email' format validation uses a regex that does not support modern email features (e.g., plus addressing, internationalized domain names), causing false negatives.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| JSON Schema Draft-07 | active | — | — |
| Ajv 8.12.0 | active | — | — |
| Python jsonschema 4.20.0 | active | — | — |
| OpenAPI 3.1.0 | active | — | — |

## Workarounds

1. **Use a custom format validator that follows RFC 5321/5322. In Python with jsonschema, register a custom validator: `import re; email_regex = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'; jsonschema.validators.create(meta_schema=..., validators={'format': lambda v, f, s: ...})`** (90% success)
   ```
   Use a custom format validator that follows RFC 5321/5322. In Python with jsonschema, register a custom validator: `import re; email_regex = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'; jsonschema.validators.create(meta_schema=..., validators={'format': lambda v, f, s: ...})`
   ```
2. **In Ajv (JavaScript), use `ajv.addFormat('email', /^[^\s@]+@[^\s@]+\.[^\s@]+$/)` to override the default email format with a more permissive regex** (85% success)
   ```
   In Ajv (JavaScript), use `ajv.addFormat('email', /^[^\s@]+@[^\s@]+\.[^\s@]+$/)` to override the default email format with a more permissive regex
   ```
3. **Switch to a validation library that supports RFC-compliant email validation, such as 'email-validator' in Python, and apply it as a custom keyword in the schema** (90% success)
   ```
   Switch to a validation library that supports RFC-compliant email validation, such as 'email-validator' in Python, and apply it as a custom keyword in the schema
   ```

## Dead Ends

- **** — Writing a custom regex that correctly validates all valid email addresses is extremely complex and often introduces new bugs (e.g., rejecting valid addresses or allowing invalid ones). (70% fail)
- **** — This disables all email validation, allowing any string to pass, which defeats the purpose of schema validation and may lead to downstream errors. (80% fail)
- **** — Not all validators support 'idn-email', and it still may reject plus signs or other common email features. (60% fail)
