README.md in phony_rails-0.14.1 vs README.md in phony_rails-0.14.2
- old
+ new
@@ -44,10 +44,27 @@
# Creates method normalized_fax_number that returns the normalized version of fax_number
phony_normalized_method :fax_number
end
```
+#### ActiveModel (models without database)
+
+For Rails-like models without a database, add:
+
+```ruby
+class SomeModel
+ include ActiveModel::Model # we get AR-like attributes and validations
+ include ActiveModel::Validations::Callbacks # a dependency for normalization
+
+ # your attributes must be defined, they are not inherited from a DB table
+ attr_accessor :phone_number, :phone_number_as_normalized
+
+ # Once the model is set up, we have the same things as with ActiveRecord
+ phony_normalize :phone_number, default_country_code: 'US'
+end
+```
+
#### Mongoid
For **Mongoid**, in keeping with Mongoid plug-in conventions you must include the `Mongoid::Phony` module:
```ruby
@@ -106,12 +123,12 @@
so we can use:
```ruby
validates_plausible_phone :phone_number, presence: true
-validates_plausible_phone :phone_number, with: /^\+\d+/
-validates_plausible_phone :phone_number, without: /^\+\d+/
-validates_plausible_phone :phone_number, presence: true, with: /^\+\d+/
+validates_plausible_phone :phone_number, with: /\A\+\d+/
+validates_plausible_phone :phone_number, without: /\A\+\d+/
+validates_plausible_phone :phone_number, presence: true, with: /\A\+\d+/
```
the i18n key is `:improbable_phone`. Languages supported by default: de, en, fr, it, ja, kh, nl, tr, ua and ru.
You can also validate if a number has the correct country number: