waiting-for-dev on test_default_with_undefined
Add missing test for a default … (compare)
flash-gordon on master
define_method is public (compare)
flash-gordon on release-1.4
Trigger build (compare)
rule(location_provided: [:address, :latitude, :longitude]) do |address, latitude, longitude| (address.filled? & latitude.filled? & longitude.filled?) | (address.none? & latitude.none? & longitude.none?) end
each attribute name repeated 4 times. Seems not readable.
I could extract internal code to some helper function like
all_or_none(address, latitude, longitude)
but this will only reduce 1 mention of each name
Is it possible to use something like this?
rule(:location_provided) do |s| #s for schema all_or_none(s.address, s.latitude, s.longitude) end
Is this something that's possible with dry-validation?
Probably not. At least dry-v should be used for other. Look at https://github.com/solnic/transproc, I use it for the same tasks as your.
dry-validation's schema to validate the inputs from an internal system, call out to one of two external APIs, massage the responses from them, and then map those responses to an internal model. The problem we're running into is that we'd like to share the schema between dry-validation and the internal model (currently using
dry-struct) but we can't really
The ability to reuse a schema in a flat / non-nested manner (issue #204) following conventions already established, like so:
schema(EmailAddress::Schema::Create) required(:email_address_id, Types::String).value(:str?)
transform_keys(&:to_sym)is the way to go.