serialize(stringify=true){// the current implementation
returnstringify?JSON.stringify(data,null,2):data;}validate(){constserialized=this.serialize(false);constvalid=validator.validate(serialized,schemas['contribution']);returnvalid?Promise.resolve():Promise.reject(validator.error);}
Let's try ro create smaller PRs for suggestions like this, instead of having them hold up larger branches from being merged.
(E.g. personally, I don't like unnamed options, so I'd probably propose to use an options object for this. But that's a completely different discussion than if the schema validation here is implemented good enough in general or not.)
What do you think?
Let's try ro create smaller PRs for suggestions like this, instead of having them hold up larger branches from being merged.
(E.g. personally, I don't like unnamed options, so I'd probably propose to use an options object for this. But that's a completely different discussion than if the schema validation here is implemented good enough in general or not.)
What do you think?
fsmanuel
(Migrated from github.com)
reviewed 2019-04-12 11:27:10 +00:00
Well I think that the initial idea to move the validation into the serializer was to get rid of the JSON.stringify ->JSON.parse thing for the validation. My suggestion is focusing on how we can prevent this.
Another thing I don't understand is why you removed the static function and don't use the class at all.
Well I think that the initial idea to move the validation into the serializer was to get rid of the `JSON.stringify` ->`JSON.parse` thing for the validation. My suggestion is focusing on how we can prevent this.
Another thing I don't understand is why you removed the static function and don't use the class at all.
raucao
(Migrated from github.com)
reviewed 2019-04-12 11:32:57 +00:00
Well I think that the initial idea to move the validation into the serializer was to get rid of the JSON.stringify ->JSON.parse thing for the validation. My suggestion is focusing on how we can prevent this.
That's not at all how I understood the idea. I merely refactored everything to be both shared modules and also do the validation in the class instead of outside.
Another thing I don't understand is why you removed the static function and don't use the class at all.
Not sure I understand. It's using only the class now, because I added more functions to it. I turned the static function into a prototype function, because that's actually using the class with prototype properties then.
> Well I think that the initial idea to move the validation into the serializer was to get rid of the `JSON.stringify` ->`JSON.parse` thing for the validation. My suggestion is focusing on how we can prevent this.
That's not at all how I understood the idea. I merely refactored everything to be both shared modules and also do the validation in the class instead of outside.
> Another thing I don't understand is why you removed the static function and don't use the class at all.
Not sure I understand. It's using only the class now, because I added more functions to it. I turned the static function into a prototype function, because that's actually using the class with prototype properties then.
raucao
(Migrated from github.com)
reviewed 2019-04-12 11:33:53 +00:00
By the way, in a way I also like validating exactly what's being stored in IPFS. I don't see it as a problem, and I don't see why a refactoring of that should keep us from merging now, as explained. I'm open to good reasons why the code in this PR doesn't work or is so bad it needs to be changed. But frankly, it seems like wasting time to me. This refactoring wouldn't even affect the code using the class from the outside. Let alone clients using the wrapper.
By the way, in a way I also like validating *exactly* what's being stored in IPFS. I don't see it as a problem, and I don't see why a refactoring of that should keep us from merging now, as explained. I'm open to good reasons why the code in this PR doesn't work or is so bad it needs to be changed. But frankly, it seems like wasting time to me. This refactoring wouldn't even affect the code using the class from the outside. Let alone clients using the wrapper.
fsmanuel
(Migrated from github.com)
reviewed 2019-04-12 12:33:24 +00:00
Let's try to create smaller PRs for suggestions like this, instead of having them hold up larger branches from being merged.
I think reviews are the place to raise this discussions, aren't they?
I was referring to this https://github.com/67P/kredits-contracts/pull/92#discussion_r274168386
So my suggestion adds little to archive this. I modified to code above to better illustrate the idea. If you disagree merge it as is.
> Let's try to create smaller PRs for suggestions like this, instead of having them hold up larger branches from being merged.
I think reviews are the place to raise this discussions, aren't they?
fsmanuel
(Migrated from github.com)
reviewed 2019-04-12 12:35:00 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
And fix seeds.
I set this to WIP, because I'm going to add proposal validation and valid proposal seeds to this as well.
Ready for review!
@@ -72,1 +51,4 @@}/*** Validate serialized data against schemaWhat about:
:shipit:
@fsmanuel what's with your comment, want to merge it?
@@ -72,1 +51,4 @@}/*** Validate serialized data against schemaLet's try ro create smaller PRs for suggestions like this, instead of having them hold up larger branches from being merged.
(E.g. personally, I don't like unnamed options, so I'd probably propose to use an options object for this. But that's a completely different discussion than if the schema validation here is implemented good enough in general or not.)
What do you think?
@@ -72,1 +51,4 @@}/*** Validate serialized data against schemaWell I think that the initial idea to move the validation into the serializer was to get rid of the
JSON.stringify->JSON.parsething for the validation. My suggestion is focusing on how we can prevent this.Another thing I don't understand is why you removed the static function and don't use the class at all.
@@ -72,1 +51,4 @@}/*** Validate serialized data against schemaThat's not at all how I understood the idea. I merely refactored everything to be both shared modules and also do the validation in the class instead of outside.
Not sure I understand. It's using only the class now, because I added more functions to it. I turned the static function into a prototype function, because that's actually using the class with prototype properties then.
@@ -72,1 +51,4 @@}/*** Validate serialized data against schemaBy the way, in a way I also like validating exactly what's being stored in IPFS. I don't see it as a problem, and I don't see why a refactoring of that should keep us from merging now, as explained. I'm open to good reasons why the code in this PR doesn't work or is so bad it needs to be changed. But frankly, it seems like wasting time to me. This refactoring wouldn't even affect the code using the class from the outside. Let alone clients using the wrapper.
@@ -72,1 +51,4 @@}/*** Validate serialized data against schemaI was referring to this https://github.com/67P/kredits-contracts/pull/92#discussion_r274168386
So my suggestion adds little to archive this. I modified to code above to better illustrate the idea. If you disagree merge it as is.
I think reviews are the place to raise this discussions, aren't they?
@@ -72,1 +51,4 @@}/*** Validate serialized data against schemaThat being said. I like your implementation!