Skip to content

Instantly share code, notes, and snippets.

View PyrinAndrii's full-sized avatar

Andrii PyrinAndrii

  • Ukraine, Lviv
View GitHub Profile
@timriley
timriley / example.rb
Created January 10, 2017 02:23
Example of dry-validation predicate for "unique within some scope"
UserSchema = Dry::Validation.Schema do
configure do
# Hard-coding the custom error messages
def self.messages
Dry::Validation::Messages.default.merge(
en: {errors: {unique_within_account?: 'is not unique within this account'}}
)
end
# Here's the custom predicate