fix: creating an event does not error when the event attribute name is too long

Signed-off-by: Calum Murray <cmurray@redhat.com>
This commit is contained in:
Calum Murray 2024-07-22 11:35:39 -04:00
parent 154e913717
commit 590e38ac66
No known key found for this signature in database
GPG Key ID: D9837BD1D90C1512
1 changed files with 2 additions and 2 deletions

View File

@ -109,9 +109,9 @@ export class CloudEvent<T = undefined> implements CloudEventV1<T> {
// finally process any remaining properties - these are extensions // finally process any remaining properties - these are extensions
for (const [key, value] of Object.entries(properties)) { for (const [key, value] of Object.entries(properties)) {
// Extension names should only allow lowercase a-z and 0-9 in the name // Extension names must only allow lowercase a-z and 0-9 in the name
// names should not exceed 20 characters in length // names should not exceed 20 characters in length
if (!key.match(/^[a-z0-9]{1,20}$/) && strict) { if (!key.match(/^[a-z0-9]+$/) && strict) {
throw new ValidationError(`invalid extension name: ${key} throw new ValidationError(`invalid extension name: ${key}
CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z')
or digits ('0' to '9') from the ASCII character set. Attribute names SHOULD or digits ('0' to '9') from the ASCII character set. Attribute names SHOULD