jimweirich / partially_valid
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
fb99654
commit fb996549578f4eec2360fd5e3283b4a867453525
tree 245cae73ae93c357c57d3ee66d102f85d199fe04
parent 3485f4f1616dd5fc9a3a5c59d7bd3a9564c3c73e
tree 245cae73ae93c357c57d3ee66d102f85d199fe04
parent 3485f4f1616dd5fc9a3a5c59d7bd3a9564c3c73e
| name | age | message | |
|---|---|---|---|
| |
README | Thu Jul 03 11:22:08 -0700 2008 | |
| |
Rakefile | Wed Jul 02 14:06:05 -0700 2008 | |
| |
init.rb | Wed Jul 02 14:06:05 -0700 2008 | |
| |
lib/ | Thu Jul 03 10:04:51 -0700 2008 | |
| |
test/ | Thu Jul 03 10:04:51 -0700 2008 |
README
h1. Partially Valid Rails Plugin PartiallyValid allows you to valid an ActiveRecord model when only a subset of the models attributes are valid. This is particularly useful when using a wizard-like UI to build up a model in stages. h1. Example Assume, for the purposes of this example that the name, age and phone number fields of a person model are required. bill = Person.new bill.partially_valid? #=> true (no fields are checked at this point) bill.should_be_partially_valid_on :name, :address bill.partially_valid? #=> false (name and address are invalid) bill.name = "Bill" bill.address = "Home Address" bill.partially_valid? #=> true (now name and address are valid) bill.should_be_partially_valid_on :phone_number bill.partially_valid? #=> false (fails now because phone number is checked) bill.should_be_partially_valid_except :phone_number bill.partially_valid? #=> true (passes now because phone number is not checked) h2. Notes After invoking :partially_valid?, the errors object will contain only errors referencing attributes declared to be considered for partial validation. The list of partially valid attributes are stored on the object itself. The object may be marshalled into session data and restored and will remember the attributes that have been declared to be checked for validity. However, the list of valid attributes are not persisted to the database. Generally, this is not a problem, because a model that is only partially valid cannot be saved to the database anyways. The :valid? method continues to work as before. h3. Requirements The flexmock gem. > gem install flexmock
