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

Support for logical implication #324

Description

@volkanunsal

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions