vuelidate

How to use conditional operator inside validations in vuelidate?

我怕爱的太早我们不能终老 提交于 2020-12-12 02:46:24
问题 I just installed vuelidate, and created a helper that checks if the value is phone no . reference import { helpers } from 'vuelidate/lib/validators'; const phone = helpers.regex('alpha', /^(09)[0-9]{9}/); My objective is, the input box should accept only email or phone_no , I tried the solution(s) below but none works. Sol. 1 validations: { username: { valid: phone or email }} Sol. 2 validations: { username: { valid: phone || email }} Someone knows how to achieve this? 回答1: Ohws I've figured

Validate form input fields in child component from a parent component with Vuelidate

隐身守侯 提交于 2019-12-08 09:13:27
I am new to Vue Js and Vuelidate. Just tried to validate form input fields from a parent component like here: https://github.com/monterail/vuelidate/issues/333 Child component in the parent: <contact-list ref="contactList" :contacts="contacts" @primaryChanged="setPrimary" @remove="removeContact" @ready="isReady => readyToSubmit = isReady"/> The method in the child: computed: { ready() { return !this.$v.email.$invalid; } }, watch: { ready(val) { this.$emit('ready', val); } }, methods: { touch() { this.$v.email.$touch(); } } I'm calling the touch() method from the parent like so: submit() { this

Validate form input fields in child component from a parent component with Vuelidate

送分小仙女□ 提交于 2019-12-08 06:19:31
问题 I am new to Vue Js and Vuelidate. Just tried to validate form input fields from a parent component like here: https://github.com/monterail/vuelidate/issues/333 Child component in the parent: <contact-list ref="contactList" :contacts="contacts" @primaryChanged="setPrimary" @remove="removeContact" @ready="isReady => readyToSubmit = isReady"/> The method in the child: computed: { ready() { return !this.$v.email.$invalid; } }, watch: { ready(val) { this.$emit('ready', val); } }, methods: { touch(

Vuelidate: validate form with sub components

强颜欢笑 提交于 2019-12-01 20:08:12
How to work with validations of nested components inside a parent component with Vuelidate ? I would like to change parentForm.$invalid if inputs in subcomponents are valid or not. Parent: <parent-component> </child-component-1> </child-component-2> </parent-component> validations: { parent: WHAT HERE? } Child-1 <child-component-1> </some-input> </child-component-1> data() { return { someInput: "" }; }, validations: { someInput: required } Child-2 <child-component-2> </some-input> </child-component-2> data() { return { someInput: "" }; }, validations: { someInput: required } Harshal Patil The

Vuelidate: validate form with sub components

我只是一个虾纸丫 提交于 2019-12-01 19:05:27
问题 How to work with validations of nested components inside a parent component with Vuelidate ? I would like to change parentForm.$invalid if inputs in subcomponents are valid or not. Parent: <parent-component> </child-component-1> </child-component-2> </parent-component> validations: { parent: WHAT HERE? } Child-1 <child-component-1> </some-input> </child-component-1> data() { return { someInput: "" }; }, validations: { someInput: required } Child-2 <child-component-2> </some-input> </child