jhthorsen / json-validator

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

Migration path from JSON::Validator::joi #221

Closed mattias-p closed 3 years ago

mattias-p commented 3 years ago

I've got a bunch of code using JSON::Validator::joi like this:

use JSON::Validator qw( joi );

sub api_key {
    return joi->string->regex('^[a-zA-Z0-9-_]{1,512}$');
}

When I run this code I get lots of deprecation warnings about this use of joi. The documentation at https://metacpan.org/pod/JSON::Validator clearly marks the joi interface as deprecated. So far, so good. However, I can't find any documentation on intended migration paths away from the deprecated interface. Also, https://metacpan.org/pod/JSON::Validator::Joi still prescribes the use of the deprecated interface.

jhthorsen commented 3 years ago

Oh. That's not very nice. I've just made a new release where you can do:

use JSON::Validator::Joi qw(joi);

The reason why JSON::Validator::joi() is deprecated is because it could also take $data which I found very clumsy.