Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Dec 14 14:41
    Travis dry-rb/dry-view (master) errored (638)
  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 14:36

    dry-bot on master

    [devtools] config sync (compare)

  • Dec 14 11:48

    flash-gordon on v1.2.2

    (compare)

  • Dec 14 11:47

    flash-gordon on master

    Update CHANGELOG (compare)

  • Dec 14 11:36
    flash-gordon closed #376
  • Dec 14 11:36

    flash-gordon on reject-string-keys

    (compare)

  • Dec 14 11:36

    flash-gordon on master

    Reject non-symbol keys in schem… Test invalid exception message Merge pull request #378 from dr… (compare)

  • Dec 14 11:36
    flash-gordon closed #378
  • Dec 14 11:24
    flash-gordon synchronize #378
Adam Davies
@adz
It uses dry struct for form object with dry validation for save call
Tim Riley
@timriley
oh that’s interesting
George Millo
@georgemillo
is there a way to use a dry struct as a type in another dry struct?
Tim Riley
@timriley
@georgemillo yep!
module Types
  include Dry::Types.module
end

class Address < Dry::Struct
  attribute :suburb, Types::Strict::String
end

class Customer < Dry::Struct
  attribute :name, Types::Strict::String
  attribute :address, Address
end

Customer.new(name: "George", address: {suburb: "Test Town”})
# => #<Customer name="George" address=#<Address suburb="Test Town">>
Rafael
@lastk
Tim Riley
@timriley
@lastk I think you might be asking in the wrong room. I think you’re after trailblazer/chat
Rafael
@lastk
ops
yes, you're right, sorry :P
Adam Davies
@adz

Following on from experimenting with dry-validations…
How would you verify uniqueness when scoped to another record?

Say “account” has many “users”, and I want users.name to be unqiue within an account….

Tim Riley
@timriley
@adz I’d write a predicate like unique_within_account?(account_id, user_name)
Adam Davies
@adz
Thanks… how would that look when called? I’m a little confused about that
Tim Riley
@timriley
lemme set something up to test :)
Adam Davies
@adz
Much appreciated !
(there’s more if click through)
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