Skip to content

Instantly share code, notes, and snippets.

@argerim
Created August 8, 2013 19:19
Show Gist options
  • Save argerim/6187780 to your computer and use it in GitHub Desktop.
Save argerim/6187780 to your computer and use it in GitHub Desktop.
Eu criei uma class Regex, ja que iria usar em outros lugares. no meu caso a data era dd/mm/aaaa
# -*- coding: utf-8 -*-
class Regex
DATE = /^(0?[1-9]|[12][0-9]|3[01])[\/](0?[1-9]|1[012])[\/]\d{4}$/
EMAIL = /\b[A-Z0-9._%a-z\-]+@(?:[A-Z0-9a-z\-]+\.)+[A-Za-z]{2,4}\z/
PHONE = /^$|^[0-9]{2}[0-9]{4}[0-9]{4}$/
STRING = /^[a-zA-ZÀ-ÿ ]+$/x
SPMOBILE = /^$|^11[0-9]{5}[0-9]{4}$/
end
validates :aniversario, format: { with: Regex::DATE , allow_blank: true }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment