README.md in phony_rails-0.4.1 vs README.md in phony_rails-0.4.2

- old
+ new

@@ -1,10 +1,10 @@ # PhonyRails (In its early days :) called PhonyNumber) -This Gem adds useful methods to your Rails app to validate, display and save phone numbers. +This small Gem adds useful methods to your Rails app to validate, display and save phone numbers. It uses the super awesome Phony gem (https://github.com/floere/phony). ## Installation Add this line to your application's Gemfile: @@ -82,45 +82,52 @@ validates_plausible_phone :phone_number, :without => /^\+\d+/ validates_plausible_phone :phone_number, :presence => true, :with => /^\+\d+/ the i18n key is `:improbable_phone` +You can also validate if a number has the correct country code: + + validates_plausible_phone :phone_number, :country_code => '61' + ### Display / Views In your views use: <%= "311012341234".phony_formatted(:format => :international, :spaces => '-') %> <%= "+31-10-12341234".phony_formatted(:format => :international, :spaces => '-') %> <%= "+31(0)1012341234".phony_formatted(:format => :international, :spaces => '-') %> To first normalize the String to a certain country use: - <%= "010-12341234".phony_formatted(normalize => :NL, :format => :international, :spaces => '-') %> + <%= "010-12341234".phony_formatted(:normalize => :NL, :format => :international, :spaces => '-') %> You can also use the bang method (phony_formatted!): number = "010-12341234" - number.phony_formatted!(normalize => :NL, :format => :international) + number.phony_formatted!(:normalize => :NL, :format => :international) number # => "+31 10 12341234" ### Find by normalized number Say you want to find a record by a phone number. Best is to normalize user input and compare to an attribute stored in the db. Home.find_by_normalized_phone_number(PhonyRails.normalize_number(params[:phone_number])) ## Changelog +0.4.2 +* Added @fareastside validation for country_code. + 0.4.0/0.4.1 -* Better Mongoid support by @johnnyshields +* Better Mongoid support by @johnnyshields. 0.3.0 * Now ability to force change a country_code. See: https://github.com/joost/phony_rails/pull/23#issuecomment-17480463 0.2.1 -* Better error handling by @k4nar +* Better error handling by @k4nar. 0.1.12 * Further loosened gemspec dependencies. 0.1.11 @@ -173,6 +180,6 @@ 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Added some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request -Thanks to all contributors: ddidier, brutuscat, henning-koch. +Don't forget to add tests and run rspec before creating a pull request :) \ No newline at end of file