New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

has_contact_number

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

has_contact_number

  • 0.4.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

HasContactNumber

Provides support for validating, storing and retrieving phone, mobile, fax numbers with ISD code.

Installation

Add this line to your application's Gemfile:

gem 'has_contact_number'

And then execute:

    $ bundle

Usage

Prerequisites

Add columns for required contact_number attributes in table.

In Model

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

In Controller

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

In View

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'

TODOs

  • Helper methods for generating fields on view
  • Field helper methods with Bootstrap, Foundation support
  • Method to format contact number as per default pattern
  • Method to format contact number as per country of ISD code
  • Method to format number as per custom pattern passed

Contributing

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.

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 11 Apr 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc