![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Provides support for validating, storing and retrieving phone, mobile, fax numbers with ISD code.
Add this line to your application's Gemfile:
gem 'has_contact_number'
And then execute:
$ bundle
Add columns for required contact_number attributes in table.
Define contact number attributes/columns in model where you have columns like phone_number, mobile_number, fax_number, etc.
contact_number_attributes :column1, :column2, :columnN
For example:
class Contact < ActiveRecord::Base
contact_number_attributes :phone_number, :mobile_number, :fax_number
end
Use method contact_number_attributes to generate list of attributes to be permitted.
For example:
class ContactsController < ApplicationController
def contact_params
params.require(:contact).permit(
*contact_number_attributes(:phone_number, :mobile_number, :fax_number), # Other attributes
)
end
end
Note: Pay attention to usage of splat operator (*
) prefixed to contact_number_attributes
You can add select list for ISD code of contact_number attribute using collection options_for_isd_code_select and text field for contact_number attribute.
For example: If you have phone_number attribute then following should be your view code (For HAML)
= f.select :phone_number_isd_code, options_for_isd_code_select, prompt: 'Select'
= f.text_field :phone_number_without_isd_code, placeholder: 'Phone Number'
You can use any FormBuilder like SimpleForm as
= f.input :phone_number_isd_code, collection: options_for_isd_code_select, prompt: 'Select'
= f.input :phone_number_without_isd_code, placeholder: 'Phone Number'
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/has_contact_number. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that has_contact_number demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.