Skip to content

Instantly share code, notes, and snippets.

@davydovanton
Created December 4, 2017 14:39
Show Gist options
  • Save davydovanton/ad1c52800bdcb972b771556f165f306e to your computer and use it in GitHub Desktop.
Save davydovanton/ad1c52800bdcb972b771556f165f306e to your computer and use it in GitHub Desktop.
module Platform
module Types
include Dry::Types.module
include ROM::Types
include ROM::SQL::Types
include ROM::SQL::Types::PG
# ...
Phone = String
.constructor(proc { |value| value.to_s.empty? ? nil : value })
.constrained(format: /\A([\d]{10}|)\z/).optional
end
end
Dry::Validation.Form do
configure do
config.type_specs = true
end
optional(:phone, Platform::Types::Phone).filled
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment