Skip to content
This repository was archived by the owner on Feb 16, 2021. It is now read-only.

Support for logical implication #324

Open
volkanunsal opened this issue Jun 25, 2018 · 0 comments
Open

Support for logical implication #324

volkanunsal opened this issue Jun 25, 2018 · 0 comments

Comments

@volkanunsal
Copy link

I'm using a backend validator that uses implications. I'd like to transform the AST that it generates into tcomb types and perform validation on the frontend before uploading the files to the server.

A simple example of this is the following.

Dry::Schema.define { 
  optional(:bar).filled 
}.to_ast

=> [:set,
 [[:and,
  [:implication,
   [[:predicate, [:key?, [[:name, :bar], [:input, Undefined]]]],
    [:key, [:bar, [:predicate, [:filled?, [[:input, Undefined]]]]]]]]]]

This is essentially checking that the optional key bar is filled if it exists in the input. But implication can also be used for password confirmation and other higher order rules.

Is there a way to implement implication to support such use cases in tcomb or one of its sister projects like io-ts?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant