File: person.rb

package info (click to toggle)
ruby-client-side-validations 3.2.6%2Bgh-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 672 kB
  • ctags: 510
  • sloc: ruby: 2,959; makefile: 2
file content (17 lines) | stat: -rw-r--r-- 344 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class PersonValidator < ActiveModel::Validator
  def validate(record)
  end
end

class Person
  include ActiveModel::Validations

  attr_accessor :first_name, :last_name, :email, :age

  validates_presence_of :first_name
  validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i

  def new_record?
    true
  end
end