Skip to content

Error on document page https://vinejs.dev/docs/types/object#groupotherwise #39

@dusterherz

Description

@dusterherz

The documentation shows this example :

vine.group([
  vine.group.if((data) => 'username' in data, {
    username: vine.string()
  }),
  vine.group.if((data) => 'email' in data, {
    email: vine.string().email()
  })
])
.otherwise((field) => {
  field.report(
    'You must provide username or email to login',
    'email_or_username',
    field
  )
})

This example does not work. otherwise need two parameters : value and field. It needs to be corrected like the example with union :

vine.group([
  vine.group.if((data) => 'username' in data, {
    username: vine.string()
  }),
  vine.group.if((data) => 'email' in data, {
    email: vine.string().email()
  })
])
.otherwise((_, field) => {
  field.report(
    'You must provide username or email to login',
    'email_or_username',
    field
  )
})

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