Skip to content

Joi.string().regex() with support for all modifiers #1429

@matuszeman

Description

@matuszeman

Context

  • joi version: <=13.1.2

What are you trying to achieve or the steps to reproduce ?

Have available all possible regex modifier - e.g. global, multiline, ... currently all are ignored except 'i'.
https://github.com/hapijs/joi/blob/master/lib/types/string/index.js#L119

Example

The schema below (if I got it right) should match base64 encoded string with fixed line-length also - multiline modifier is used.

const schema = Joi.string().regex(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}(==)?|[A-Za-z0-9+\/]{3}=?)?$/m;)

Metadata

Metadata

Assignees

Labels

breaking changesChange that can breaking existing codefeatureNew functionality or improvement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions