atournayre/types
Lightweight PHP library providing reusable types/value objects. Installable via Composer, intended to standardize and validate common domain data. Open-source on GitHub with issue tracker and MIT license.
Type Safety & Developer Experience (DX):
EmailAddress type utility enables stricter validation for email-related logic, reducing runtime errors in user-facing flows (e.g., authentication, notifications). This aligns with security and compliance needs (e.g., GDPR, email deliverability).MustVerifyEmail trait and Illuminate\Validation\Rules\Email by offering runtime type enforcement (e.g., EmailAddress::validate($input)) alongside validation rules.Roadmap Acceleration:
EmailAddress::ensureValid().// Before: Loose validation
if (filter_var($email, FILTER_VALIDATE_EMAIL)) { ... }
// After: Strong typing
$email = EmailAddress::fromString($request->input('email'));
EmailAddress in OpenAPI/Swagger schemas or GraphQL input types to enforce consistency between frontend and backend.Use Cases (Expanded):
user@example early).from/to addresses in queues (e.g., Laravel’s Mailable) are typed correctly.Adopt if:
EmailAddress as a method return type in a User service).strpos($email, '@')) to modern PHP types.Look elsewhere if:
Email rule or filter_var).phpstan/extension-installer for static analysis).egulias/email-validator for RFC compliance).*"This update adds specialized email type safety to our PHP toolkit—critical for reducing errors in user flows like sign-ups and password resets. For example, it catches invalid emails like user@example before they hit our database, saving support costs and improving deliverability.
Impact:
Ask: ‘Would you prioritize cutting support tickets from bad email data over a small dev training investment?’
*"Problem: Email validation is still a runtime wild west—even with Laravel’s rules, we get user@example slipping through. The new EmailAddress type adds:
EmailAddress::validate() in services).User model attributes).Why now?
Next steps:
EmailAddress for 1 sprint.User DTOs to use EmailAddress as a property type.Risk: None—drop-in replacement for existing validation. If it’s not a fit, we can revert easily.*
Ask: ‘Can we test this in the auth service before the next release?’"*
How can I help you explore Laravel packages today?