Comments (8)
I don't have any particular love or hate for AJV. But do you have another suggested tool for schema validation? AJV gets 31 million downloads a week, so I think it's probably pretty well liked.
from sdk-javascript.
Can you help me understand why you think that JSON schema validation makes creating CloudEvent instances difficult? I don't follow.
from sdk-javascript.
The issue is around AJV.
https://github.com/cloudevents/sdk-javascript/blob/master/lib/specs/spec_1.js#L36
which expects a file like:
https://github.com/cloudevents/sdk-javascript/blob/master/ext/spec_1.json
and uses boilerplate like this:
https://github.com/cloudevents/sdk-javascript/blob/master/lib/specs/spec_1.js#L111-L201
Rather than creating this boilerplate, I suggest we remove AJV. This will make it possible to do things like fix this issue around directly using JSON: #65
from sdk-javascript.
However, it looks to me like that's not what AJV is used for in this case. If you look at the commit history of that file, you can see that it appears to have been hand written. In this case, AJV is not being used to generate code, rather it is being used to validate input, which I think is a reasonable usage of the module since that input may be incorrect.
It's certainly reasonable to want to simplify this file, but I don't think removing data validation checks is necessarily required to do so.
from sdk-javascript.
OK, so if we want to keep the feature to validate the input, I suggest we use a different tool than AJV for the isValidAgainstSchema
method. Perhaps in a validate_ce.js
file rather than the main spec file. Is that fine?
from sdk-javascript.
I don't have any particular love or hate for AJV. But do you have another suggested tool for schema validation? AJV get's 31 million downloads a week, so I think it's probably pretty well liked.
I'll look into it. It might just be the way we use the library with our current format and not the validator itself.
from sdk-javascript.
@grant I think that the schema validator is actually really important and would be a lot of work to replace manually (and would not be as fast/efficient as AJV). It is sometimes valuable to have the capability to determine if a CloudEvent is actually valid per the specification and that's what this does. I can see an argument for decoupling the validator from the CloudEvent
class itself and exposing it as a function. But I don't see value in removing this capability altogether. I think this issue should be closed, or perhaps you have something in mind that I'm not aware of.
from sdk-javascript.
Yeah, the usage now is a lot cleaner than it was before.
It does take 60% of the bundle size, so I was a little concerned if we're trying to slim this package down.
Maybe it could an optional dependency in the future.
Should be fine to keep until there's a better suggestion.
from sdk-javascript.
Related Issues (20)
- Binary mode header missing extension attribute when the value is false (boolean)
- Validation is broken HOT 1
- Issue converting a golang cloudevents type Kafka message HOT 3
- Unnecessary polyfill for http and https required HOT 3
- Harmonize validation of CloudEvents HOT 9
- Avoid jest#13535 and planttheidea/fast-equals#91
- [security] Potential XSS in httpTransport() HOT 3
- Does not work in browsers as of 5.3.1 HOT 1
- Add the engines property to the package.json HOT 1
- Add Tests for the Browser version HOT 2
- No .d.ts files available for browser bundle HOT 1
- Add Test Runner for Node 18 LTS HOT 1
- Can't resolve 'http' error when using on React app HOT 11
- Vulnerability of util version 0.12.5 HOT 2
- Invalid default data for parsing in binary mode HOT 7
- Getting error when installing on node 20.0.0
- Compatible with Node 20.x HOT 1
- Add support for request timeout in HTTP transport HOT 2
- HTTP headers name case for extensions HOT 3
- Unable to retrieve data from the HTTP request HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdk-javascript.