Krutarth Dave
Krutarth Dave

Reputation: 1

joi schema uri validation not giving error for invalid uri

I have this joi schema for a field:

link: Joi.string()
    .uri({ scheme: ['https'] })
    .max(256)
    .required()
    .error((error: JoiError[]) => new Error('link not valid') as string)),

and the entry that is being validated is: https:/quillbot.com/grammar-check

now notice that there is only one '/' after https: instead of double like 'https://' - which should produce an error. But it is not throwing an error. What should I do to correct the behaviour.?

I tried without the scheme options, regex doesn't really seem the best approach as far as I have seen the examples on the internet.

Update: I updated the scheme to be 'https://' instead of just 'https' - and it works, but I still want to know why the other was not working properly.?

Upvotes: 0

Views: 67

Answers (0)

Related Questions