Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: base
CloudEvent
class as per v1 specs, including attribute validation #242feat: base
CloudEvent
class as per v1 specs, including attribute validation #242Changes from 3 commits
a2ac762
8db1e29
35dee7d
42b4fe1
f83c363
9d1aa35
aa81ca0
b2b0649
b202325
c5e6df9
6e13f72
e78a70b
443aee9
1d43d68
21493e1
68337f9
d0bba86
599d05c
43f1d0c
7d18098
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's probably a good idea to:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My goal is to have this validation logic in a single place, it's easier to follow IMO and read it, rather than navigate into multiple small methods.
About extracting reusable logic, I can try to look into this, but I also wanted to have it "match" the spec and treat each attribute as individual. Again, for readability reasons mainly. It's easier to reason about when the whole validation logic is colocated.
I'm a fan of "fail fast" approach, what would be an advantage of raising all exceptions at once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about something like this?
and each method will hold the necessary validation logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grouping CloudEvents (CE) attributes validation with
required
andoptional
as well as having a separateextension
rules is IMO a good idea.On the fail fast approach - sure, that's a valid one, but IMO not in this case. I guess people would only see the validation errors when they are developing against CE, not during active usage (hopefully). So it makes sense to gather all the validation errors all together and present them together to ease analysis of a defective event. I'd probably even go and create a custom error instead of using standard ones with more details on what and where has failed the validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my brief experience using CloudEvents with Python and Java SDK, the validation usually fails at runtime, in production 😅 it's where all the random crap gets into the events for different reasons. I'm fine with returning all the validation errors at once, not my first option, but I'll do it.