mirror of
https://github.com/Respect/Validation.git
synced 2026-03-17 07:45:45 +01:00
Improves SPDX header linting to ensure consistent license metadata across the codebase. Key changes: - Enforce deterministic tag ordering (License-Identifier, FileCopyrightText, FileContributor) to ensure consistency, prevent merge conflicts, and simplify code reviews - Add contributor alias mapping to consolidate contributors with multiple emails or name variations (e.g., "nickl-" → "Nick Lombard") - Add --contributions-strategy option with "blame" (current code authors) and "log" (all historical contributors) to support different attribution philosophies - Add optional path argument to lint specific files or directories - Add --fix option to automatically correct header issues Assisted-by: Claude Code (claude-opus-4-5-20251101)
66 lines
2.2 KiB
Markdown
66 lines
2.2 KiB
Markdown
<!--
|
|
SPDX-License-Identifier: MIT
|
|
SPDX-FileCopyrightText: (c) Respect Project Contributors
|
|
-->
|
|
|
|
# SubdivisionCode
|
|
|
|
- `SubdivisionCode(string $countryCode)`
|
|
|
|
Validates subdivision country codes according to [ISO 3166-2][].
|
|
|
|
The `$countryCode` must be a country in [ISO 3166-1 alpha-2][] format.
|
|
|
|
**This validator requires [sokil/php-isocodes][] and [php-isocodes-db-only][] to be installed.**
|
|
|
|
```php
|
|
v::subdivisionCode('BR')->assert('SP');
|
|
// Validation passes successfully
|
|
|
|
v::subdivisionCode('US')->assert('CA');
|
|
// Validation passes successfully
|
|
```
|
|
|
|
## Templates
|
|
|
|
### `SubdivisionCode::TEMPLATE_STANDARD`
|
|
|
|
| Mode | Template |
|
|
| ---------: | :----------------------------------------------------------------------- |
|
|
| `default` | {{subject}} must be a subdivision code of {{countryName|trans}} |
|
|
| `inverted` | {{subject}} must not be a subdivision code of {{countryName|trans}} |
|
|
|
|
## Template placeholders
|
|
|
|
| Placeholder | Description |
|
|
| ------------- | ---------------------------------------------------------------- |
|
|
| `countryName` | |
|
|
| `subject` | The validated input or the custom validator name (if specified). |
|
|
|
|
## Categorization
|
|
|
|
- ISO codes
|
|
- Localization
|
|
|
|
## Changelog
|
|
|
|
| Version | Description |
|
|
| ------: | :---------------------------------------------------------------- |
|
|
| 3.0.0 | Require [sokil/php-isocodes][] and [sokil/php-isocodes-db-only][] |
|
|
| 1.0.0 | Created |
|
|
|
|
## See Also
|
|
|
|
- [Circuit](Circuit.md)
|
|
- [CountryCode](CountryCode.md)
|
|
- [CurrencyCode](CurrencyCode.md)
|
|
- [Nip](Nip.md)
|
|
- [Pesel](Pesel.md)
|
|
- [PolishIdCard](PolishIdCard.md)
|
|
- [PublicDomainSuffix](PublicDomainSuffix.md)
|
|
- [Tld](Tld.md)
|
|
|
|
[ISO 3166-1 alpha-2]: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 "ISO 3166-1 alpha-2"
|
|
[ISO 3166-2]: http://en.wikipedia.org/wiki/ISO_3166-2 "ISO 3166-2"
|
|
[sokil/php-isocodes]: https://github.com/sokil/php-isocodes
|
|
[sokil/php-isocodes-db-only]: https://github.com/sokil/php-isocodes-db-only
|