Skip to content

Instantly share code, notes, and snippets.

@sled

sled/example1.rb Secret

Created April 21, 2016 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sled/d29f90880b8f8f2fe56a38a34f1cc8ca to your computer and use it in GitHub Desktop.
Save sled/d29f90880b8f8f2fe56a38a34f1cc8ca to your computer and use it in GitHub Desktop.
Create = Dry::Validation.Form do
key(:organization_id).required
key(:code).required
rule(:unique_code_organization) do
!Code.exists?(code: value(:code), organization_id: value(:organization_id))
end
configure do
option :market_repo, WheelsApp.instance["repositories.market"]
end
end
Create = Dry::Validation.Form do
key(:organization_id).required
key(:code).required(:uniq?)
rule(:unique_code_organization) do
!Code.exists?(code: value(:code), organization_id: value(:organization_id))
end
configure do
option :market_repo, WheelsApp.instance["repositories.market"]
def uniq?(code)
!Code.exists?(code: code, organization_id: value(:organization_id))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment