Skip to content

elfproef enables rails-applications to check dutch social security numbers or dutch bank-account numbers

License

Notifications You must be signed in to change notification settings

l-plan/elfproef_plan

Repository files navigation

ElfproefPlan

Installation

Add this line to your application's Gemfile:

gem 'elfproef_plan'

And then execute:

$ bundle

Or install it yourself as:

$ gem install elfproef_plan

Why this gem

Main purpose is to provide boilerplate code to L-Plan-applications which require the validation af a social-security- or bankaccount- number.

  • ElfProef
    • pure ruby check
    • rails validation
    • javascript tool

class ElfproefPlan::ElfProef

###initialize ElfproefPlan::ElfProef.new takes only one parameter, an integer or a string. Either one will be conversed internally into an array, on which you can invoke two methods:

  • validRekenening for a bank-accountnumber

  • validBsn for a dutch bsn-number

the output will be true or false

use these for server-side validations

###validations

in any model just include

validates :my_attribute_name, bsn: true

or optional

validates :my_attribute_name, bsn: {message: "this message overrides the default"}
validates :my_attribute_name, rekeningnummer: true

or optional

validates :my_attribute_name, rekeningnummer: {message: "this message overrides the default"}
validates :my_attribute_name, loonheffingennummer: true

or optional

validates :my_attribute_name, loonheffingennummer: {message: "this message overrides the default"}

it will handle validations just like rails does with other validations.

the rekening-validation just validates the plain, old accountnumber. Validation of BIC-code is yet to be implemented.

elfproef.js.coffee

ElfProef takes an value, and validates the given number/string.

  • it calls ElfProef.new(@value).validBsn() to check a bsn-number

  • it calls ElfProef.new(@value).validRek() to check a bank-account-number

  • it calls ElfProef.new(@value).validLoonheffingennummer() to check a tax-number

To use these client-side checks, just add a class "checkMyBsn","checkMyRekening" or "checkMyLoonheffing" to your input-field. Add a div with class "rekening_message", "bsn_message" or "loonheffing_message" to your form to display the returned message.

The code can be included by requiring elfproef_plan, or just the elfproef-file:

//= require elfproef_plan

or

//= require elfproef/elfproef

To call a check on another field, alter the following code to your liking.

example:

$ ->
  $(document).on 'blur', '.checkMyBsn',  ->
    if new ElfProef(@value).validBsn()
      $(".bsn_message").text("ok")
    else
      $(".bsn_message").text("geen geldig bsn-nummer")

Gem Version

About

elfproef enables rails-applications to check dutch social security numbers or dutch bank-account numbers

Resources

License

Stars

Watchers

Forks

Packages

No packages published