Created
December 4, 2017 14:39
-
-
Save davydovanton/ad1c52800bdcb972b771556f165f306e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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