jhthorsen / json-validator

:cop: Validate data against a JSON schema
https://metacpan.org/release/JSON-Validator
56 stars 58 forks source link

adding error code to JSON::Validator::Error #129

Closed beyondcreed closed 5 years ago

beyondcreed commented 5 years ago

just curious if it would be possible to add error_code to JSON::Validator::Error

e.g.

use JSON::Validator::Error;
my $err = JSON::Validator::Error->new($path, $message, $error_code);

use case for this would be to localize on front-end the message based on specific error code returned by API, could likely use message to stuff the code, but thought it would be cleaner to keep it separate.

jhthorsen commented 5 years ago

@beyondcreed: I just made #130. Maybe you want to give me some feedback on that instead?

beyondcreed commented 5 years ago

sure, I'll head over there

jhthorsen commented 5 years ago

How would the error code help you? Can you give me some examples of what they might be and how you would use them?

beyondcreed commented 5 years ago

I commented on #130 with sample use case. you can check there.

jhthorsen commented 5 years ago

Could you also have a look at https://github.com/mojolicious/json-validator/pull/133 to see what you think about that PR?