Skip to content

built-in type validators missing useful information #9488

@yocontra

Description

@yocontra

What are you doing?

We expect to be able to return useful validation errors for our API users/UI to understand - to do so we need the field name the error is for. With custom validation errors, we get that information and can use it to highlight fields in the UI - with any core type, we get no information other than the value that failed. It would be extremely useful if all validation errors were the same, no matter if it was a core type or custom type. If you agree I can send a PR shortly since this is a pretty easy fix.

Model.validate({ id: '1234' })

What do you expect to happen?

An error resembling other validation errors, complete with an errors array, each item containing validatorKey, path, value, and message.

What is actually happening?

The only information in the error is the message attribute:

"1234" is not a valid uuid

Dialect: any
Sequelize version: 5.x
Tested with latest release: Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions