fix: ensure source property has min length of 1 (#438)
Fixes: https://github.com/cloudevents/sdk-javascript/issues/383 Signed-off-by: Lance Ball <lball@redhat.com>
This commit is contained in:
parent
2dc846c659
commit
2ff7852c36
|
@ -79,6 +79,7 @@ export const schemaV1 = {
|
|||
source: {
|
||||
format: "uri-reference",
|
||||
type: "string",
|
||||
minLength: 1,
|
||||
},
|
||||
},
|
||||
type: "object",
|
||||
|
|
|
@ -209,4 +209,20 @@ describe("A 1.0 CloudEvent", () => {
|
|||
expect(obj.source).to.equal(source);
|
||||
expect(obj.specversion).to.equal(Version.V1);
|
||||
});
|
||||
|
||||
it("throws if the provded source is empty string", () => {
|
||||
try {
|
||||
new CloudEvent({
|
||||
id: "0815",
|
||||
specversion: "1.0",
|
||||
type: "my.event.type",
|
||||
source: "",
|
||||
});
|
||||
} catch (err) {
|
||||
expect(err).to.be.instanceOf(TypeError);
|
||||
expect(err.message).to.include("invalid payload");
|
||||
expect(err.errors[0].dataPath).to.equal(".source");
|
||||
expect(err.errors[0].keyword).to.equal("minLength");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue