Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 11:07

    flash-gordon on master

    Add more predicates to mapping (compare)

  • 11:04
    timriley synchronize #155
  • 11:04

    timriley on rich-component-dirs-config

    Use base Dry::Container missing… (compare)

  • 10:56
    timriley synchronize #155
  • 10:56

    timriley on rich-component-dirs-config

    Make load_component easier to u… (compare)

  • 09:49

    dry-bot on master

    [devtools] sync (compare)

  • 09:48

    flash-gordon on master

    Make predicate inference truly … Update changelog.yml (compare)

  • Jan 17 13:25
    flash-gordon review_requested #415
  • Jan 17 13:25
    flash-gordon review_requested #415
  • Jan 17 13:25
    flash-gordon opened #415
  • Jan 17 13:21

    flash-gordon on custom-builder-methods

    Support for custom builder meth… (compare)

  • Jan 17 12:37
    flash-gordon synchronize #413
  • Jan 17 12:37

    flash-gordon on or_nil-extension

    Add Type#or_nil via builders ex… (compare)

  • Jan 17 12:30

    dry-bot on master

    [devtools] sync (compare)

  • Jan 17 12:30

    flash-gordon on master

    Fix changelog (compare)

  • Jan 17 10:28

    dry-bot on master

    [devtools] sync (compare)

  • Jan 17 10:28

    flash-gordon on master

    Update changelog.yml Add reminder (compare)

  • Jan 17 10:11

    flash-gordon on deprecate-class-name-inferring

    (compare)

  • Jan 17 10:11

    flash-gordon on master

    Deprecate predicate inferring f… Merge pull request #414 from dr… (compare)

  • Jan 17 10:11
    flash-gordon closed #414
Adam Davies
@adz
got it...
how would it look if “unique_within_account?” had a third param?
name.unique_within_account?(account_id)
-> ?
Tim Riley
@timriley
the “value under test” is always the last param for custom predicates
so it’d be def unique_within?(first, second, the_value)
and fo name.unique_within?(“foo”, “bar”), first would be ”foo”, second would be ”bar”
is that what you’re after?
Adam Davies
@adz
ah ok… yeah
trying different things and I think there are issues with docs
Tim Riley
@timriley
Sorry about that :grimacing:
Adam Davies
@adz
it shows like
required(:email).filled(scoped_unique?: :email, scope?: { active: true })
… i guess . does it change when under the ‘filled’?
defined inside configure:
def scoped_unique?(attr_name, scope, value)
Tim Riley
@timriley
well, it’s just a different way of running that predicate
.filled(prdicate_name?: :args_go_here)
Adam Davies
@adz
i understand it changes to “filled? & …"
Tim Riley
@timriley
lemme try
I don’t think you can do that short-hand use of the predicates if you’re depending on another input value
the high-level rules work because they only run if the input values they require have passed any other validations
in that way they’re “safe”
and e.g. our predicate method can rely on its args being a certain type
Adam Davies
@adz
In examples above I’m referring to docs here http://dry-rb.org/gems/dry-validation/comparison-with-activemodel/
Tim Riley
@timriley
yeah. that’s passing static values as predicate args
Adam Davies
@adz
Ok i get that… but i read it as ‘scope?’ being a diff predicate

so… if there are two args
`.filled(prdicate_name?: :args_go_here)

would it be:

`.filled(prdicate_name?: [:arg1, :arg2])

Tim Riley
@timriley
yes
they’re splatted
Adam Davies
@adz
so it doesn’t make sense in the example, right?
Tim Riley
@timriley
no :(
Adam Davies
@adz

required(:email).filled(scoped_unique?: :email, scope?: { active: true })

should be

required(:email).filled(scoped_unique?: [:email, { active: true }])

Tim Riley
@timriley
yeah
Adam Davies
@adz
its hard when you don’t know how the DSL is structured… i’m kind of inferring from examples
getting clearer
Ok — @timriley i updated my PR to the docs to correct
dry-rb/dry-rb.org#138 let me know if that is correct now?
Adam Davies
@adz

One more thing — is it possible to infer the key of the predicate being tested?

that “required(:email).filled(unique?: :email)” has to repeat the ‘email’ key as an arg

Tim Riley
@timriley
@adz AFAIK the predicates don’t know which key they’re being used on, no
I thought there might’ve been a GH issue about this, but I can’t find it.
Adam Davies
@adz
ok
Adam Davies
@adz
Anyone use dry pipeline? Seems like dry transaction supersedes it with similar functionality
Tim Riley
@timriley
Yeah, dry-pipeline never really went anywhere
rom has something like it built internally for function composition but it’s not separate
Adam Davies
@adz
I feel the urge to chain functions and seems to fit
Tim Riley
@timriley
yeah, I use dry-monads and return monads to do that
maybe the pipeline thing is useful in other kinds of cases
Adam Davies
@adz
Doing elm has corrupted me such that I'm uncomfortable with mutations :0
Tim Riley
@timriley
:)
Adam Davies
@adz
This message was deleted
This message was deleted