joi string .regex() check string containing number digits only

Created on 18 Apr 2019  路  2Comments  路  Source: sideway/joi

I was tring to validate string to contain only digits from 0 to 9 using regex but it doesn't work with me as expected.

joi.string().trim().regex(/[0-9]/).max(15)

support

Most helpful comment

You have to anchor your regex like ^[0-9]+$.

All 2 comments

You have to anchor your regex like ^[0-9]+$.

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

REBELinBLUE picture REBELinBLUE  路  3Comments

ashrafkm picture ashrafkm  路  3Comments

jamesdixon picture jamesdixon  路  4Comments

neroaugustus1 picture neroaugustus1  路  4Comments

farwayer picture farwayer  路  3Comments