Samuel Elliott
31ea83eb89
Adding Proc support to validation messages so that they can become a little more dynamic, allowing for customisations during the request [ #3514 status:resolved].
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-01-17 14:40:10 +01:00
José Valim
b078f7fd39
Fix typos and add tests to ensure they will be caught the next time.
2010-01-11 23:38:35 +01:00
José Valim
017f5d5308
Fix typo by renaming :genre to :gender.
2010-01-09 00:18:07 +01:00
José Valim
7045c4c279
Allow validates to map some types to specific options. So now you can do:
...
validates :email, :presence => true, :format => /@/
validates :genre, :inclusion => %w(m f)
validates :password, :length => 6..20
2010-01-08 21:36:04 +01:00
José Valim
fa14d6d51e
Compile length validator options still at the class level, so whenever the validator is called, it just needs to check for :maximum, :minimum and :is values.
2010-01-08 21:36:04 +01:00
José Valim
47a5fd4c4b
Allow :if, :unless, :on, :allow_nil and :allow_blank as shared options in validates.
2010-01-07 19:23:59 +01:00
jamie
0a79eb7889
Add validates method as shortcut to setup validators for a given set of attributes:
...
class Person < ActiveRecord::Base
include MyValidators
validates :name, :presence => true, :uniqueness => true, :length => { :maximum => 100 }
validates :email, :presence => true, :email => true
end
[#3058 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com >
2010-01-07 19:23:59 +01:00
José Valim
a25ef06956
Allow to specify default attributes names translation in I18n yml files.
...
For example, you could easily specify :created_at and :updated_at translations as:
en:
attributes:
created_at: "Created at"
updated_at: "Updated at"
This configuration is built on ActiveModel, so it means those translations are
shared between different ORMs as well (but always as a fallback).
2010-01-07 15:31:50 +01:00
José Valim
b0572ab2b6
Be sure to dup load paths before clearing the array.
2010-01-07 15:31:50 +01:00
José Valim
190ce3ab37
Errors messages are now moved from :activerecord.errors to simply :errors on I18n yml files.
2010-01-07 15:31:49 +01:00
Joshua Peek
e5ed62deea
Autoload AR test case
2010-01-04 16:50:01 -06:00
Joshua Peek
640d9e7e32
Autoload AMo test case
2010-01-04 16:29:07 -06:00
José Valim
4796be33a4
Add missing tests to Validators.
2010-01-03 17:14:50 +01:00
José Valim
08986ce290
Remove deprecated ActiveModel tests (%d and %s is no longer supported in error messages a couple months already)
2010-01-02 22:27:03 +01:00
José Valim
653fa4c10c
Add naming to AMo::Lint
2010-01-02 22:27:02 +01:00
José Valim
7cc0a4cfa1
Use activerecord.errors.format as in Rails 2.3.5.
2010-01-02 22:27:02 +01:00
José Valim
5fdd0e80a4
Be sure to convert namespaced names to we have 'Parrots name' instead of 'Parrots.name' in error messages.
2010-01-02 22:27:02 +01:00
José Valim
6d390671f6
Move ActiveRecord callbacks implementation to ActiveModel and make use of it.
...
Signed-off-by: Yehuda Katz <wycats@Yehuda-Katz.local >
2009-12-28 16:19:23 -08:00
José Valim
74098e4cb6
No need to use ValidationsRepairHelper hack on ActiveModel anymore, Model.reset_callbacks(:validate) is enough. However, tests in ActiveRecord are still coupled, so moved ValidationsRepairHelper back there.
2009-12-23 13:30:58 +01:00
José Valim
e31077c9aa
Small clean up in Naming and TTranslation tests.
2009-12-23 12:28:02 +01:00
José Valim
f1085f4128
Move validations in ActiveModel to validators, however all validatity checks are still in the class method.
2009-12-23 00:36:51 +01:00
José Valim
2476c5312d
Validator is simply sent to validate method. However, the API needs to change, so validate accepts a record.
2009-12-22 23:12:21 +01:00
Joshua Peek
7ee5843c3c
Fully expand relative rails framework paths and make sure we aren't
...
adding any to the load path more than once.
2009-12-16 11:56:51 -06:00
Carlhuda
c1304098cc
Reorganize autoloads:
...
* A new module (ActiveSupport::Autoload) is provide that extends
autoloading with new behavior.
* All autoloads in modules that have extended ActiveSupport::Autoload
will be eagerly required in threadsafe environments
* Autoloads can optionally leave off the path if the path is the same
as full_constant_name.underscore
* It is possible to specify that a group of autoloads live under an
additional path. For instance, all of ActionDispatch's middlewares
are ActionDispatch::MiddlewareName, but they live under
"action_dispatch/middlewares/middleware_name"
* It is possible to specify that a group of autoloads are all found
at the same path. For instance, a number of exceptions might all
be declared there.
* One consequence of this is that testing-related constants are not
autoloaded. To get the testing helpers for a given component,
require "component_name/test_case". For instance, "action_controller/test_case".
* test_help.rb, which is automatically required by a Rails application's
test helper, requires the test_case.rb for all active components, so
this change will not be disruptive in existing or new applications.
2009-12-02 20:01:08 -08:00
Joshua Peek
11e798ae0f
Avoid adding component lib/ to load path multiple times
2009-11-09 23:28:36 -06:00
José Valim
e714b499cc
Move validator, human_name and human_attribute_name to ActiveModel, remove deprecated error messages and add i18n_scope and lookup_ancestors.
...
Signed-off-by: Carl Lerche <carllerche@mac.com >
2009-10-20 17:52:32 -07:00
Yehuda Katz + Carl Lerche
4f6d6f7031
Have all the tests running off a single Gemfile
2009-10-20 16:34:44 -07:00
Yehuda Katz
02b76862e1
Bundle AMo
2009-10-15 14:04:18 -07:00
Joshua Peek
ff56f3d5e1
Rewrite ActiveModel::Lint as a simple TU mixin
2009-10-07 09:24:51 -05:00
Sam Pohlenz
4df96338ed
Fixed behavior of attribute_methods_generated? [ #3220 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-10-07 09:07:39 -05:00
Sam Pohlenz
f8e91bda9c
Don't share attribute matchers between classes [ #3216 state:resolved]
...
Allows separate models that include ActiveModel::AttributeMethods to
use different sets of attribute matchers.
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-10-07 09:07:39 -05:00
Jeremy Kemper
38e056ee2a
Use ActiveModel::TestCase base class
2009-09-24 22:56:30 -07:00
Akira Matsuda
0990a13500
Ensure validation errors to be ordered in declared order
...
[#2301 state:committed milestone:2.3.5]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-09-11 18:52:22 -07:00
José Valim
4f37b97033
Changed ActiveRecord to use new callbacks and speed up observers by only notifying events that are actually being consumed.
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-09-08 10:26:39 -05:00
Joshua Peek
6dc9ad80e6
Fix warnings in AMo
2009-09-05 19:10:21 -05:00
Joshua Peek
c6e0923245
Fix failing AMo isolated tests
2009-09-05 18:54:19 -05:00
Kane
cf9f361699
added proc and symbol support to validates_numericality_of [ #3049 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-08-31 13:35:14 -05:00
Yehuda Katz
dbf20c2dbb
Initial AMo Lint implementation
2009-08-29 01:49:18 -05:00
Pratik Naik
25e5b0c4a8
Remove support for SQLite 2.
...
If you're still using it, please install the plugin from git://github.com/rails/sqlite2_adapter.git
2009-08-17 14:54:34 +01:00
Elliot Winkler
cccb0e6b93
Add validates_format_of :without => /regexp/ option [Elliot Winkler, Peer Allan]
...
[#430 state:resolved]
Example :
validates_format_of :subdomain, :without => /www|admin|mail/
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2009-08-10 15:22:31 +01:00
Jeff Dean
22f3398253
Introduce validates_with to encapsulate attribute validations in a class.
...
[#2630 state:committed]
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net >
2009-08-09 22:47:56 -07:00
Adam Keys
5632b36701
Fix exclusive range patch to use begin/end instead of min/max. [ #2981 status:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
Signed-off-by: Pratik Naik <pratiknaik@gmail.com >
2009-08-08 23:42:18 +01:00
Pratik Naik
c6fe49b009
Simplyfy validates_length_of and remove puts
2009-08-08 19:08:39 +01:00
jzw
5ab94b2595
validates_length_of with maximum should allow nil [ #2309 status:resolved]
...
Signed-off-by: José Valim <jose.valim@gmail.com >
2009-08-08 19:08:13 +01:00
James Hill
cfd421daa2
Allow validations to use values from custom readers [ #2936 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-08-05 11:45:01 -05:00
Joshua Peek
272c504f91
Dasherize XML root by default to avoid invalid tags "<admin/posts>...</admin/posts>" [ #2875 state:resolved]
2009-07-22 21:06:34 -05:00
John Maxwell
c39151a847
Patch to ActiveModel's (and ActiveRecord, by association) XML serialization: If two parameters are present in Procs supplied to to_xml's :procs option, the model being serialized will be passed as the second argument [ #2373 state:resolved]
...
Signed-off-by: Joshua Peek <josh@joshpeek.com >
2009-07-22 20:47:15 -05:00
Joshua Peek
6944b391cd
Kill AMo Base
2009-07-21 00:13:26 -05:00
Joshua Peek
2685d93b07
Kill AMo ivar attributes helper
2009-07-20 23:28:58 -05:00
Joshua Peek
d2b78b3594
Initial extraction of AMo xml serializer
2009-07-03 21:38:14 -05:00