aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/validations.rb
Commit message (Collapse)AuthorAgeFilesLines
* Association validation does not belong in a before_save callback: move it ↵Jeremy Kemper2005-10-021-3/+7
| | | | | | into a validation method. Restores the expected model.valid? == model.save. Add tests for cancelling save by returning false from a before_save callback. Remove assumption that before_destroy's return value indicates whether the record was destroyed. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2434 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* r3604@asus: jeremy | 2005-09-26 19:10:42 -0700Jeremy Kemper2005-09-261-20/+29
| | | | | | | Treat validates_size_of :within as a single validator rather than splitting it into to ends of the range, thus yield two error messages on nil (yuck) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2355 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Make update_attribute use the same writer method that update_attributes uses.Marcel Molina2005-09-261-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2353 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Refactored to a more readble form #1813David Heinemeier Hansson2005-09-111-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2202 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fix typo in validations documentation #1938 [court3nay]Jamis Buck2005-08-141-1/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2010 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed validates_numericality_of to work with overrided getter-method when ↵David Heinemeier Hansson2005-07-021-0/+1
| | | | | | :allow_nil is on #1316 [raidel@onemail.at] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1603 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Clarified intentions of validates_associated #870David Heinemeier Hansson2005-07-021-1/+4
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1602 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Updated all references to the old find_first and find_all to use the new ↵David Heinemeier Hansson2005-06-261-2/+2
| | | | | | style #1511 [Marcel Molina] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1520 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed that validations didn't respecting custom setting for too_short, ↵David Heinemeier Hansson2005-06-251-7/+3
| | | | | | too_long messages #1437 [Marcel Molina] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1509 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added ActiveRecord::Recursion to guard against recursive calls to #saveJamis Buck2005-06-131-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1411 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added Errors#add_on_blank which works like Errors#add_on_empty, but uses ↵David Heinemeier Hansson2005-05-211-6/+15
| | | | | | Object#blank? instead. CHANGED: validates_presence_of now uses Errors#add_on_blank, which will make " " fail the validation where it didnt before #1309. Added that " " is now also blank? (using strip if available) git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1346 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added the :if option to all validations that can either use a block or a ↵David Heinemeier Hansson2005-05-211-5/+66
| | | | | | method pointer to determine whether the validation should be run or not. #1324 [Duane Johnson/jhosteny] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1340 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed docs for scaffolding generator #1303 [thijs@vandervossen.net]David Heinemeier Hansson2005-05-191-2/+0
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1312 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed that validate_length_of lost :on option when :within was specified ↵David Heinemeier Hansson2005-04-301-3/+5
| | | | | | #1195 [jhosteny@mac.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1258 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added validates_exclusion_of as a negative of validates_inclusion_ofDavid Heinemeier Hansson2005-04-241-0/+25
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1236 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed documentation and prepared for release of 0.12David Heinemeier Hansson2005-04-181-3/+3
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1216 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added Base.save! that attempts to save the record just like Base.save but ↵David Heinemeier Hansson2005-04-181-0/+9
| | | | | | will raise a InvalidRecord exception instead of returning false if the record is not valid [After much pestering from Dave Thomas] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1215 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added the option to specify the acceptance string in validates_acceptance_of ↵David Heinemeier Hansson2005-04-171-3/+5
| | | | | | #1106 [caleb@aei-tech.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1188 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Cleaned up validates_length_of by calling existing validations on the common ↵David Heinemeier Hansson2005-04-171-29/+17
| | | | | | stuff #1108 [caleb@aei-tech.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1178 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Address parsing failed when the "to" (or "cc", or whatever) was an array. It ↵David Heinemeier Hansson2005-04-131-4/+4
| | | | | | was also too restrictive in the formats of the addresses #1097 [Jamis] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1149 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added optionally allow for nil or empty strings with ↵David Heinemeier Hansson2005-03-141-56/+46
| | | | | | validates_numericality_of #801 [Sebastian Kanthak] Fixed problem with using slashes in validates_format_of regular expressions #801 [Sebastian Kanthak] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@910 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added validates_numericality_of #716 [skanthak/c.r.mcgrath]David Heinemeier Hansson2005-03-061-42/+76
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@842 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Finished polishing API docsDavid Heinemeier Hansson2005-02-231-1/+3
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@773 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed that when using validation macros with a custom message, if you ↵David Heinemeier Hansson2005-02-221-3/+11
| | | | | | happened to use single quotes in the message string you would get a parsing error #657 [tonka] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@740 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added validates_each that validates each specified attribute against a block ↵David Heinemeier Hansson2005-02-181-181/+254
| | | | | | #610 [bitsweat]. Added :allow_nil as an explicit option for validates_length_of, so unless that's set to true having the attribute as nil will also return an error if a range is specified as :within #610 [bitsweat] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@667 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Addded validation for validate all the associated objects before declaring ↵David Heinemeier Hansson2005-02-171-3/+3
| | | | | | failure with validates_associated #618 [Tim Bates]. Added that validates_* now accept blocks to perform validations #618 [Tim Bates] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@650 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed documentation snafus #575, #576, #577, #585David Heinemeier Hansson2005-02-071-3/+3
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@525 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed documentation #538David Heinemeier Hansson2005-01-251-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@503 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Replaced === checks with is_a? checks #502, #82 [Marcel Molina]David Heinemeier Hansson2005-01-201-2/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@466 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added validates_associated that enables validation of objects in an unsaved ↵David Heinemeier Hansson2005-01-151-0/+33
| | | | | | association #398 [Tim Bates] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@418 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed Base#update_attribute to be indifferent to whether a string or symbol ↵David Heinemeier Hansson2005-01-061-1/+1
| | | | | | is used to describe the name git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@341 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed #406 for realDavid Heinemeier Hansson2005-01-041-2/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@329 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed that validates_uniqueness_of used 'id' instead of defined primary key #406David Heinemeier Hansson2005-01-041-2/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@328 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed quoting in validates_format_of that would allow some rules to pass ↵David Heinemeier Hansson2004-12-311-1/+1
| | | | | | regardless of input #390 [Dmitry V. Sabanin] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@288 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added scope option to validation_uniqueness #349 [Kent Sibilev]David Heinemeier Hansson2004-12-221-2/+7
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@259 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added allow_nil options to validates_inclusion_of so that validation is only ↵David Heinemeier Hansson2004-12-221-1/+7
| | | | | | triggered if the attribute is not nil [what-a-day] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@258 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed that overriding an attribute's accessor would be disregarded by ↵David Heinemeier Hansson2004-12-221-4/+9
| | | | | | add_on_empty and add_on_boundary_breaking because they simply used the attributes[] hash instead of checking for @base.respond_to?(attr.to_s). [Marten] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@247 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed validates_{confirmation,acceptance}_of to only happen when the virtual ↵David Heinemeier Hansson2004-12-211-4/+6
| | | | | | attributes are not nil #348 [dpiddy@gmail.com] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@241 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Reworded a few doc things for better comprehension [dblack]David Heinemeier Hansson2004-12-191-3/+3
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@226 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fixed small doc bug [dblack]David Heinemeier Hansson2004-12-191-1/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@225 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Made the last tweaks before 0.9David Heinemeier Hansson2004-12-161-3/+2
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@197 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Updated and added more documentationDavid Heinemeier Hansson2004-12-161-31/+28
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@193 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added Base.validates_inclusion_ofDavid Heinemeier Hansson2004-12-161-10/+64
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@192 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Renamed Mixins to Acts to resemble the change from include ↵David Heinemeier Hansson2004-12-161-12/+12
| | | | | | ActiveRecord::Mixins::List to acts_as_list and renamed @@default_error_messagess to @@default_error_messages git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@190 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added Base.validates_inclusion_of that validates whether the value of the ↵David Heinemeier Hansson2004-12-161-0/+23
| | | | | | specified attribute is available in a particular enumerable object. [what-a-day] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@179 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added Base.validates_format_of that Validates whether the value of the ↵David Heinemeier Hansson2004-12-161-6/+28
| | | | | | specified attribute is of the correct form by matching it against the regular expression provided. [Marcel] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@174 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added Base.default_error_messages as a hash of all the error messages used ↵David Heinemeier Hansson2004-12-151-9/+22
| | | | | | in the validates_*_of so they can be changed in one place [Tobias Luetke] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@173 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Added Base.validates_boundries_of that delegates to add_on_boundary_breaking ↵David Heinemeier Hansson2004-12-151-18/+37
| | | | | | #312 [Tobias Luetke] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@166 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Insignificante...David Heinemeier Hansson2004-12-151-0/+1
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@162 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Changed validate_* to validates_*_of, so validate_acceptance becomes ↵David Heinemeier Hansson2004-12-151-56/+27
| | | | | | validates_acceptance_of, and added :on as a configuration option instead of using _on_create/update git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@157 5ecf4fe2-1ee6-0310-87b1-e25e094e27de