Skip to content

Commit

Permalink
migrate uniqueness validator to the new DSL
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Feb 28, 2023
1 parent 27fffc1 commit cd67a52
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/goo/validators/implementations/unique.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module Goo
module Validators
class Unique < ValidatorBase
include Validator

key :unique

error_message ->(obj) { "`#{@attr}` must be unique. " +
"There are other model instances with the same attribute value `#{@value}`."}

validity_check -> (obj) do
return true if @value.nil?

!Goo::SPARQL::Queries.duplicate_attribute_value?(@inst,@attr)
end


end
end
end

0 comments on commit cd67a52

Please sign in to comment.