[Vuejs]-How can I check file types with Vuelidate?

2👍

✅

You can use helpers validator with regex check. More info here

import { helpers, required } from 'vuelidate/lib/validators'

const imageRule = helpers.regex('image', /\.(gif|jpe?g|tiff|png)$/)

export default {
    data() {
        return {
            image: '',
        }
    },
    validations: {
        image: {
            required,
            imageRule
        },
    },
}

Leave a comment