You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The field name is missing only display {field} placeholder when using built-in rules and useField API
To reproduce
Steps to reproduce the behavior:
Install vee-validate, import all the built-in rules -> it only displays 1 default message with different rules
i.e Test is not valid with required rule, also Test is not valid with numeric rule
Use config API to config generateMessage with @vee-validate/i18n and en.json
import { localize } from '@vee-validate/i18n'
import en from '@vee-validate/i18n/dist/locale/en.json'
import * as rules from '@vee-validate/rules'
import { configure, defineRule } from 'vee-validate'
configure({
generateMessage: localize({ en })
})
type ValidationRuleFunction = (
value: any,
params: any[] | Record<string, any>,
ctx: FieldContext
) => boolean | string | Promise<boolean | string>
interface FieldContext {
field: string
value: any
form: Record<string, any>
rule: {
name: string
params?: Record<string, any> | any[]
}
}
Object.keys(rules).forEach((rule: string) => {
defineRule(rule, (rules as Record<string, ValidationRuleFunction>)[rule])
})
Message is now correct base on built-in rules but now field name is missing only display {field}
Expected behavior
Display field name correctly, display the built-in rules message correctly
The text was updated successfully, but these errors were encountered:
andy3520
changed the title
The field name is missing only display {_field_} placeholder when using built-in rules and useField API
[V4] The field name is missing only display {_field_} placeholder when using built-in rules and useField API
Aug 24, 2020
function interpolate(template, values) {
return template.replace(/{([^}]+)}/g, function (_, p) {
console.log('match:', _);
console.log('p:', p);
console.log('values:', values);
console.log('p in values:', p in values);
return p in values ? values[p] : `{${p}}`;
});
}
Result:
match: {_field_}
p: _field_
values: {email: "", password: "asdf", field: "email"}
p in values: false
andy3520
changed the title
[V4] The field name is missing only display {_field_} placeholder when using built-in rules and useField API
[v4] The field name is missing only display {_field_} placeholder when using built-in rules and useField API
Aug 27, 2020
Versions
Describe the bug
The field name is missing only display {field} placeholder when using built-in rules and useField API
To reproduce
Steps to reproduce the behavior:
i.e
Test is not valid
withrequired
rule, alsoTest is not valid
withnumeric rule
generateMessage
with@vee-validate/i18n
anden.json
Expected behavior
Display field name correctly, display the built-in rules message correctly
The text was updated successfully, but these errors were encountered: