Validation File


#1

What’s Happening? The erros have the same message! How to fix this?

oie_zeRINBZ1kO3F

And more, this part of the code is being ignored!

get messages () {
        return {
            'foto.required': 'Custom message',
            'foto.file': 'Custom message',
            'foto.file_ext': 'Custom message',
            'foto.file_size': 'Custom message'
        }
    }

#2

because you’re only allowing images extensions, for example:

png or jpg

but you´re trying to upload a pdf file, so in order to allow it, try including it into your rule

maybe: file_ext: png, jpg, jpeg, pdf


#3

Can you share the contents of complete validator file?


#4
class FotoStore {
    get validateAll () {
        return true
    }

    get rules () {
        return {
            foto: 'required|file|file_ext:png,jpg,jpeg|file_size:1mb'
        }
    }

    get messages () {
        return {
            'foto.required': 'Custom message',
            'foto.file': 'Custom message',
            'foto.file_ext': 'Custom message',
            'foto.file_size': 'Custom message'
        }
    }

    async fails (errorMessages) {
        return this.ctx.response
            .status(403)
            .send({ message: 'Falha durante o envio da imagem', errors: errorMessages })
    }
}

#5

No no Shadow. I tried to send a PDF because I wanted to generate this error.