Socket
Book a DemoInstallSign in
Socket

ico-validator

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ico-validator

0.5.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

ico-validator

Build Status Dependency Status Code Climate Test Coverage

Ruby validator for format of Czech company identification number - ICO

Contains:

  • Standalone ruby validator
  • Rails ActiveModel::EachValidator
  • JS validator

What is validated:

Usage

Ruby validator

Ruby validator is one simple module with only one public method IcoValidation.valid_ico? which returns true or false.

require 'ico_validator'

IcoValidation.valid_ico?('12345678') # invalid ico
=> false

IcoValidation.valid_ico?('27169278')
=> true

Rails validator

Rails validator is implemented as ActiveModel::EachValidator. So it's easy to use within your AR models:

class Company < ActiveRecord::Base
  validates :ico, ico: true
end

If validation doesn't pass it adds :invalid_format error on validated attribute.

JS validation

ico-validator is Rails engine, so if you want to validate ico with javascript just add following to application.js

//= require ico-validator

And then on any field you want to be validated with JS:

<%= form_for(...) do |f| %>
  <%= f.text_field :ico, class: 'ico-validate' %>
<% end %>

jQuery will bind validations there.

FAQs

Package last updated on 14 Nov 2016

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.