vinejs / vine

VineJS is a form data validation library for Node.js

Home Page:https://vinejs.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dot notation not working in "otherField"

erwinstone opened this issue · comments

Package version

1.6.0

Describe the bug

const schema = vine.object({
  old: vine.object({
    username: vine.string(),
    password: vine.string(),
  }),
  new_username: vine.string().notSameAs('old.username'), // <-- this
  new_password: vine.string().notSameAs('old.password'), // <-- this
})

const data = {
  old: {
    username: 'admin',
    password: 'secret',
  },
  new_username: 'admin',
  new_password: 'secret',
}

await vine.validate({ schema, data }) // pass

For example, the notSameAs rule accepts otherField as a parameter, but it's not working if otherField is from an object key.

Reproduction repo

No response

The dot-notation is not supported. But I see how it can be useful to support it. Will work on the same :)