Skip to content
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

[Question] How to get the label of target field in cross-field custom rule? #2301

Closed
lephuongbg opened this issue Sep 6, 2019 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@lephuongbg
Copy link

Is there a way to get the target field's label from its vid in getMessage function? I'm writing a cross-field custom rule, e.g after_date:target_field. What I want to achieve is to return a message like {validatingFieldLabel} should be after {targetFieldLabel}.

Any help is appreciated!

Pseudo code:

Validator.extend('after_date', {
    getMessage(validatingFieldLabel, [targetFieldVid]) {
        // How to get targetFieldLabel from targetFieldVid?
        return `{validatingFieldLabel} should be after {targetFieldLabel}`
    },
    validate(after, [before]) {
        // Validation logic here
    }
}, {hasTarget: true})
@logaretm logaretm added the duplicate This issue or pull request already exists label Sep 6, 2019
@logaretm
Copy link
Owner

logaretm commented Sep 6, 2019

If you are using v3 This is a duplicate of #2290

closing in favor of tracking it in that one.

@logaretm logaretm closed this as completed Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants