Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mask_validator

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mask_validator

  • 0.2.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Mask Validator

Gem Version

This gem was inspired in the Sobrinho's gems to validate simple things inside of ActiveModel.

The gem works getting the value before type cast and comparing with a regular expression from the parse of mask pattern.

Installation

Put gem "mask_validator", "0.2.1" in the Gemfile

Usage

validates :phone, :mask => "(99) 9999-9999"

validates :acronym, :mask => "***"

validates :acronym, :mask => :custom_method

validates :acronym, :mask => Proc.new { |o| o.custom_method }
  • a - Represents an alpha character (A-Z, a-z)
  • 9 - Represents a numeric character (0-9)
      • Represents an alphanumeric character (A-Z, a-z, 0-9)

For more information about masks in the form inputs check the jquery plugin Masked input

Application example

Use a little trick to call the masked input (jquery plugin) only defining the validation in the model.

In other words, defining:

validates :phone, :mask => "(99) 9999-9999"

It is the only necessary thing to apply the masked input.

License

Copyright © 2011 Marcelo Cajueiro, released under the MIT license

FAQs

Package last updated on 08 Jan 2015

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