-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add match regex attribute #1760
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, only thing is, I am not sure if the error
message would actually work like this if we are thinking of translatable mcdoc. But I guess the attribute is not that relevant for vanilla-mcdoc anyways.
I do have some usecases for this attribute in my map, so I would love this feature :D
I think it's acceptible that the custom error message is not translatable |
const regex = RegExp(pattern) | ||
if (!regex.test(value)) { | ||
if (config.message) { | ||
ctx.err.report(config.message, node, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctx.err.report(config.message, node, 2) | |
ctx.err.report(config.message, node, core.ErrorSeverity.Warning) |
You missed this :p
Adds an attribute
match_regex
that allows for regex validation for string fields.Regex config is required but error is not. If error is not provided will use a default error message instead.
#[match_regex=(regex=foo, error="error")]