Schrank :shopware: 🐘 (er/ihm) on Nostr: Is this a design pattern and if yes, how it is called? interface AddressValidator { ...
Is this a design pattern and if yes, how it is called?
interface AddressValidator {
isSupported(string $country): bool;
validateAddress(Address $a): Address
}
class GermanValidator implements AddressValidator {}
class FranceValidator implements AddressValidator {}
class MetaValidator implements AddressValidator {
__construct(AddressValidator ...$validator)
// run through the validator and find one for the address -> country and use it.
}
First we use GermanValidator, but later we use Meta.
Published at
2025-05-22 22:06:18Event JSON
{
"id": "96443655dc217255adc66229b142d50cd03285b054c3f36f7a741c5e97028137",
"pubkey": "06b490b71f3af0969360bddf41610c249a0f625a37f4c9154b493b2ce067e639",
"created_at": 1747951578,
"kind": 1,
"tags": [
[
"proxy",
"https://phpc.social/users/Schrank/statuses/114553754632500616",
"activitypub"
],
[
"client",
"Mostr",
"31990:6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9:mostr",
"wss://relay.mostr.pub"
]
],
"content": "Is this a design pattern and if yes, how it is called?\n\ninterface AddressValidator {\nisSupported(string $country): bool;\nvalidateAddress(Address $a): Address\n}\n\nclass GermanValidator implements AddressValidator {}\nclass FranceValidator implements AddressValidator {}\n\nclass MetaValidator implements AddressValidator {\n__construct(AddressValidator ...$validator)\n// run through the validator and find one for the address -\u003e country and use it.\n}\n\nFirst we use GermanValidator, but later we use Meta.",
"sig": "b130c9a95c7cd8d3a64b2f82ea6b085549fbc74fbd438ca149714ab7aa4e23ae40c1e3bf661181f498f95522a4129fb265d2f27b8e33b73d93863adce323f07f"
}