public
Description: Some ActiveRecord Extensions
Homepage: http://simplificator.com
Clone URL: git://github.com/simplificator/arext.git
pascalbetz (author)
Wed May 27 23:40:40 -0700 2009
commit  ae4f818ec85470c9c88e7d278119265529703f0e
tree    328847f85debbc2a754483b0c6ed244d666c7083
parent  5fa50af9143d00caf8338d4bdedc7764985dedac
arext /
name age message
file .document Wed May 27 09:34:01 -0700 2009 moved gem to jeweler [pascalbetz]
file .gitignore Wed May 27 09:34:01 -0700 2009 moved gem to jeweler [pascalbetz]
file LICENSE Wed May 27 09:34:01 -0700 2009 moved gem to jeweler [pascalbetz]
file README.rdoc Wed May 27 09:34:01 -0700 2009 moved gem to jeweler [pascalbetz]
file Rakefile Wed May 27 23:40:23 -0700 2009 exluded sqlite files [pascalbetz]
file VERSION.yml Wed May 27 23:40:40 -0700 2009 Version bump to 0.3.1 [pascalbetz]
file arext.gemspec Loading commit data...
directory lib/ Thu Oct 09 00:15:51 -0700 2008 extend arext with validates_email [marco]
directory test/ Wed May 27 09:26:09 -0700 2009 removed init file; not needed [pascalbetz]
README.rdoc

Arext

Active Record Extensions.

Validations

validates_constraints

This uses the information one can extract from ActiveRecord::ConnectionAdapter::Column to add default validations. The text?, limit and type methods are used to guess what validations are to be added validates_constraints make some assumptions (see below) and none of its behaviour is configurable. (you can always use the standard validations in addition to make some adjustments)

 * Adds validates_presence_of for columns with not null constraints (unless type is :boolean)
   * options are added so that empty strings will pass, unlike if you add the validate_presence_of yourself.
     If you want to have different behaviour then just add a validation yourself
 * Adds validates_inclusion_of(:in => [true, false]) for columns with not null constraints and :boolean type
 * Adds validates_length_of for text columns with not null limit

validates_url

This validator adds the feature to validate urls with http and https protocols. It also include portnumbers and any subdomains. Instead of a domain name, you can use ip address too (version 4).

validates_host

This validator adds the feature to validate a hostname. Instead of a hostname, you can use ip address too (version 4).

validates_email

This validator adds the feature to validate a email address.

Example

=

validates_constraints

in your ActiveRecord class:

 validate_constraints(:attribute_name, :other_attribute_name)

or

 validates_constraints() for all attributes

validates_url

in your ActiveRecord class:

  validates_url(:attribute)

validates_host

in your ActiveRecord class:

  validates_host(:attribute)

validates_email

in your ActiveRecord class:

  validates_email(:attribute)

Copyright © 2008 - now [simplificator gmbh]