A RFC-compliant email validation library for Common Lisp.
- RFC 5321 compliant email validation
- Validates local part (before @) and domain part (after @)
- Supports special characters allowed by RFC
- Supports IP literals (IPv4 and IPv6)
- Enforces proper length limits:
- Local part: max 64 characters
- Domain labels: max 63 characters
- Total email: max 320 characters
- ASCII-only validation (no Unicode)
- Zero dependencies
This library uses ASDF for system definition.
-
Clone to a location where ASDF can find it:
cd ~/common-lisp/ # or ~/quicklisp/local-projects/ git clone <repository-url> email-validator
-
Load the system:
(asdf:load-system :email-validator)
(ql:quickload :email-validator);; Load the system
(asdf:load-system :email-validator)
;; Validate email addresses
(email-validator:email-p "[email protected]") ; => T
(email-validator:email-p "invalid.email") ; => NIL
(email-validator:email-p "@invalid.com") ; => NIL
(email-validator:email-p "user@") ; => NIL
;; Advanced examples
(email-validator:email-p "[email protected]") ; => T
(email-validator:email-p "user@[192.168.1.1]") ; => T
(email-validator:email-p "user@[IPv6:2001:db8::1]") ; => T(email-p email)→boolean
Returns T if the email is valid according to RFC specifications, NIL otherwise.
- Max 64 characters
- Allowed characters: alphanumeric +
. ! # $ % & ' * + - / = ? ^ _{ | } ~` - Cannot start or end with a dot
- No consecutive dots
- ASCII only
- Domain names: standard DNS rules
- IP literals:
[192.168.1.1]or[IPv6:2001:db8::1] - Labels max 63 characters each
- Must have at least 2 labels (e.g.,
example.com) - ASCII only
- Single @ symbol required
- Max 320 characters total
- Must be a string
;; Run all tests
(asdf:test-system :email-validator)
;; Or load and run directly
(asdf:load-system :email-validator/tests)
(email-validator.tests:run-tests)The test suite includes 43 comprehensive tests covering valid emails, invalid emails, edge cases, and RFC compliance.
See example.lisp for interactive examples and usage patterns.
- Support for quoted strings in local parts (RFC 5321)
- Email address comments parsing
- Internationalized domain names (IDN) support
- Unicode/non-ASCII character validation
- Advanced RFC format compatibility
- Performance optimizations
- Extended API with detailed validation results
- Batch validation support
- Configurable validation strictness levels
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass:
(asdf:test-system :email-validator) - Submit a pull request
MIT License - see LICENSE file for details.
Created by mtha790