-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
bugBug or defectBug or defectfeatureNew functionality or improvementNew functionality or improvement
Milestone
Description
Support plan
- which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise):
Community - is this issue currently blocking your project? (yes/no):
no - is this issue affecting a production system? (yes/no):
yes
Context
- node version: any
- module version: 17.1.1
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...):
standalone - any other relevant information:
What problem are you trying to solve?
While I can just solve this with a regex, it would be much cleaner if this was part of the Joi API.
JavaScript's parseInt already natively handles the 0x prefix.
const somePrefixedHexString = '0x123';
Joi.string().hex().validate(somePrefixedHexString); // errorDo you have a new or modified API suggestion to solve the problem?
It would be amazing if I didn't have to store that regular-expression somewhere and I instead could do the following:
const somePrefixedHexString = '0x123'
Joi.string().hex({ prefix: true }).validate(somePrefixedHexString); // passes validationReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugBug or defectBug or defectfeatureNew functionality or improvementNew functionality or improvement