From da845d6fbdd81dbcee3b7aef60f6e0e0964b7e22 Mon Sep 17 00:00:00 2001 From: Eleazar Resendez Date: Tue, 29 Oct 2024 14:01:10 -0600 Subject: [PATCH] Use Mustache to render dynamic labels in validation mixin --- src/components/mixins/validation.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/mixins/validation.js b/src/components/mixins/validation.js index 0056128..92a172b 100644 --- a/src/components/mixins/validation.js +++ b/src/components/mixins/validation.js @@ -2,6 +2,7 @@ import Validator from "@chantouchsek/validatorjs"; import moment from "moment-timezone"; import ProxyData from "./ProxyData"; import { get, has } from "lodash"; +import Mustache from "mustache"; export default { name: "ValidationMixin", @@ -140,7 +141,8 @@ export default { this.validator = new Validator(data, rules, { validationMessages: this.validationMessages ? this.validationMessages : null }); - this.validator.setAttributeNames({ [fieldName]: this.label }); + const renderedLabel = Mustache.render(this.label, data); + this.validator.setAttributeNames({ [fieldName]: renderedLabel }); this.validator.errors.first(this.name); // Validation will not run until you call passes/fails on it this.validator.passes();