Feat: Improve invalid resource template messages (#245)

This commit is contained in:
Sule-Balogun Olanrewaju 2026-02-13 20:46:03 +00:00 • committed by GitHub
commit aafac3ddf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -59,10 +59,10 @@ class ResourceTemplate implements \JsonSerializable
public readonly ?array $meta = null,
) {
if (!preg_match(self::RESOURCE_NAME_PATTERN, $name)) {
throw new InvalidArgumentException('Invalid resource name: must contain only alphanumeric characters, underscores, and hyphens.');
throw new InvalidArgumentException(\sprintf('Invalid resource name "%s": must contain only alphanumeric characters, underscores, and hyphens.', $name));
}
if (!preg_match(self::URI_TEMPLATE_PATTERN, $uriTemplate)) {
throw new InvalidArgumentException('Invalid URI template: must be a valid URI template with at least one placeholder.');
throw new InvalidArgumentException(\sprintf('Invalid URI template : "%s" must be a valid URI template with at least one placeholder.', $uriTemplate));
}
}