globalbrain / sefirot

Global Brain Design System.
https://sefirot.globalbrains.com
MIT License
151 stars 12 forks source link

[Validation] Allow rule only field #447

Closed kiaking closed 5 months ago

kiaking commented 7 months ago

Currently, useV can only define keys that exist in the given data. But there are cases where having virtual field only for validation makes sense. Can we make this possible?

const { data } = useD({
  firstName: '',
  lastName: ''
})

const { validation } = useV(data, {
  // This gives type error right now.
  fullName: {
    require: rule(() => {
      return data.value.firstName && data.value.lastName
    })
  }
})
brc-dd commented 5 months ago

Bit tricky without casting. Maybe just set fullName: undefined in useD call 👀

kiaking commented 5 months ago

Hmmm yeah make sense 👀 Let's go with that 👍