Skip to content

Add enum sugar for prop validators #7840

@Justineo

Description

@Justineo

What problem does this feature solve?

For enum props, it's common to validate the given value against valid enum values like this:

props: {
  position: {
    type: String,
    validator (val) {
      return ['top', 'right', 'bottom', 'left'].includes(val)
    }
  }
}

What does the proposed API look like?

I think it'll be handy to provide extra convenience by supporting this:

props: {
  position: {
    type: String,
    validator: ['top', 'right', 'bottom', 'left']
  }
}

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