Skip to content

Instantly share code, notes, and snippets.

@bnadlerjr
Created July 29, 2012 19:07
Show Gist options
  • Select an option

  • Save bnadlerjr/3201217 to your computer and use it in GitHub Desktop.

Select an option

Save bnadlerjr/3201217 to your computer and use it in GitHub Desktop.
Validator Example
require 'validus'
class PersonValidator
include Validus
def initialize(attributes)
@attributes = attributes
end
def validate
errors.add(:name, 'cannot be blank') if @attributes[:name] == ''
end
end
validator = PersonValidator.new({ :name => 'John' })
validator.valid? # => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment