globalbrain/sefirot

[Validation] Allow rule only field

Closed this issue ยท 2 comments

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
    })
  }
})

Bit tricky without casting. Maybe just set fullName: undefined in useD call ๐Ÿ‘€

Hmmm yeah make sense ๐Ÿ‘€ Let's go with that ๐Ÿ‘