Skip to content

Instantly share code, notes, and snippets.

@alanmaciel
Created February 26, 2018 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanmaciel/2a193a391e156ead5349f718d92e4e4c to your computer and use it in GitHub Desktop.
Save alanmaciel/2a193a391e156ead5349f718d92e4e4c to your computer and use it in GitHub Desktop.
validates :title, :released_on, :duration, presence: true
validates :description, length: { minimum: 25 }
validates :total_gross, numericality: { greater_than_or_equal_to: 0 }
validates :image_file_name, allow_blank: true, format: {
with: /\w+\.(gif|jpg|png)\z/i,
message: "must reference a GIF, JPG, or PNG image"
}
RATINGS = %w(G PG PG-13 R NC-17)
validates :rating, inclusion: { in: RATINGS }
validates :name, presence: true
validates :email, presence: true,
format: /\A\S+@\S+\z/,
uniqueness: { case_sensitive: false }
validates :password, length: { minimum: 10, allow_blank: true }
validates_format_of :username,·
:with => /\A[A-Za-z\d_]+$\z/,·
:message => "can only be alphanumeric with no spaces"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment