timriley on remove-auto-register
Remove commented code (compare)
timriley on remove-auto-register
Remove no-longer-relevant doc (compare)
timriley on remove-auto-register
Remove another unneeded splat (compare)
timriley on remove-auto-register
Li’l tweak (compare)
timriley on remove-auto-register
Li’l tweak (compare)
timriley on remove-auto-register
Simplify args passed to build_f… (compare)
timriley on remove-auto-register
Further simplify args for build… (compare)
timriley on remove-auto-register
Remove `auto_register!` and add… Provide the default loader to a… Simplify args passed to build_f… (compare)
timriley on rich-component-dirs-config
Accept plain options hash inste… (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