Skip to content
Discussion options

You must be logged in to vote

In Regle rules have to be independant to be reusable, if they can access sibling properties there is no way to have a correct type safe way to do it. In your case it's simple to have a workaround.

1

Use dateBefore rule that already handles this

2

Make your MyRules reactive

export function MyRules(state: MyRecord)  {
	return {
	     to: {
		required: (value: Date | null) => {
			// require "to" only for subscriptions
			// "to" should be greater than "from"
	    },
    }
}
const {r$) = useRegle(currentState, () => MyRules(currentState.value))

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@khorsky
Comment options

Answer selected by khorsky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants