Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for the :transformer node #6

Open
wants to merge 3 commits into
base: all-work-and-no-play
Choose a base branch
from

Conversation

green-coder
Copy link
Owner

Fixes issue #5

@green-coder
Copy link
Owner Author

@borkdude Here is an example of how it works:

(m/describe (h/transform (h/vector-of (h/fn int?))
                         (h/repeat 2 3 (h/fn odd?))
                         (fn [out-data] (map inc out-data))
                         (fn [in-data] (mapv #(* % 10) in-data)))
            [2 4 6])
;=> [30 50 70]

@borkdude
Copy link

I'm getting :invalid with this example. Would it be more comprehensible if transform got an opts map instead of 4 positional args? Can you explain what "inner model" and "outer model" is in more detail?

@green-coder
Copy link
Owner Author

green-coder commented Aug 12, 2020

I tried the example again, it works on my computer.

I'm getting :invalid with this example.

Strange, it works on my computer. Did you use the second commit that I added yesterday?

Would it be more comprehensible if transform got an opts map instead of 4 positional args?

That's a good idea.

Can you explain what "inner model" and "outer model" is in more detail?

The transform node is a bridge between 2 models. I named them outer-model and the inner-model.
The outer model is the one used before you cross the bridge, and the inner model is on the other side of the bridge.
The functions outer->inner and outer<-inner are transforming the data which is validated / parsed / generated as you cross the bridge.

In practice, the outer model is used mainly to ensure a valid data format before calling outer->inner on it.

I might iterate again on this PR and change the format of the node to cover a more general way to bridge.

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

Successfully merging this pull request may close these issues.

2 participants