- How do I install laravel-validation-rules/timezone?
- Install it with Composer by running composer require laravel-validation-rules/timezone. Laravel's package auto-discovery should register the service provider automatically, so no manual entry in config/app.php is needed. After that you can reference the timezone rule in your validation rules.
- How do I use the timezone rule in a Laravel form request?
- Add the rule to the rules() array of your FormRequest, for example 'timezone' => ['required', 'timezone']. The rule resolves the submitted value against PHP's supported IANA timezone identifiers and returns a standard validation error when it does not match. You can also combine it with required, string, or nullable depending on your form.
- Which Laravel and PHP versions does this package support?
- The package is a framework-native validation extension intended for Laravel applications using Composer auto-discovery. Exact Laravel and PHP version constraints live in its composer.json, so verify them for the release you install, especially since the 1.7.0 release notes do not enumerate changes. It does not require database migrations or published config.
- Does the rule accept UTC offsets like +02:00 or abbreviations like EST?
- It checks whether the value is a valid timezone identifier in PHP's timezone_identifiers_list(), which is the IANA/Olson database. Fixed UTC offsets such as +02:00 and abbreviations such as EST are generally rejected because they are not canonical identifiers. Confirm that matches your product intent before you enforce it strictly.
- Does it normalize deprecated timezone IDs like Europe/Kiev to Europe/Kyiv?
- No, the rule is a validator, not a normalizer. It answers whether PHP currently considers the identifier valid; it does not map deprecated names like Europe/Kiev to Europe/Kyiv or convert offsets into a concrete zone. If you need canonical storage, add a separate normalization step after validation.
- Do I need to publish config or run migrations for this package?
- You should not need to publish configuration or run migrations. The package is a stateless validation rule registered through its service provider. The main setup is the Composer require and adding the rule where timezone input enters your application.
- Can I use it with Validator::make instead of a FormRequest?
- Yes. You can use it with Validator::make() the same way as any other rule, for example Validator::make($data, ['timezone' => ['required', 'timezone']]). That makes it useful in controllers, API endpoints, jobs, or tests where a FormRequest is not practical.
- Can I customize the invalid timezone error message?
- Laravel handles the rule like other validators, so you can customize messages through the messages() method on a FormRequest or the third argument to Validator::make(). The package's default message will state that the timezone is invalid; a custom message is useful when you want to guide users toward a picker or expected format.
- What should I check before enforcing it on existing timezone data?
- Before enforcing the rule, audit existing timezone values, especially ones stored as offsets, abbreviations, or deprecated identifiers. Those values will fail validation even though they may have worked in your UI before. A common approach is to validate new input immediately and backfill or normalize old records.
- Is this package safe for long-term use or should I vendor the rule?
- The 1.7.0 release is a small single-purpose package with a bare changelog, so inspect the 1.6.0 to 1.7.0 diff before upgrading and confirm composer constraints. If long-term supply-chain control matters, the rule is simple enough to vendor or reimplement with in_array($value, timezone_identifiers_list(), true). Either way, accepted identifiers follow the host's PHP tzdata.