I want to validate a JSON with an url parameter.
const schema = joi.object().keys({
imageUrl: joi.string().uri().trim().required(),
});
The following URL does fail.
https://images.internetstores.de/products//517873/02/ca8433/Keen_Oakridge_WP_Shoes_Women_Magnet_Rose[1000x700].jpg?forceSize=true&forceAspectRatio=true
The error is
child "imageUrl" fails because ["imageUrl" must be a valid uri]
but as you can easily verify, the url is valid.
Validation failed.
Validation succeeds.
It is indeed invalid as per RFC mentioned in the docs. The brackets should be percent encoded.
And since this has come up before:
just because a url resolves and loads a resource does not mean it is a valid uri per the RFCs. And RFCs rule all. :)
Most helpful comment
And since this has come up before:
just because a url resolves and loads a resource does not mean it is a valid uri per the RFCs. And RFCs rule all. :)