lion/packages/input-iban
github-actions[bot] ad697dbcd2 Version Packages
2020-12-07 13:18:25 +00:00
..
src fix: display IsIBAN message for country validators if Unparseable 2020-12-03 19:02:40 +01:00
test chore: allow array for IsNotCountryIBAN 2020-12-03 18:33:16 +01:00
translations chore: allow array for IsNotCountryIBAN 2020-12-03 18:33:16 +01:00
CHANGELOG.md Version Packages 2020-12-07 13:18:25 +00:00
index.js feat(input-iban): add IsNotCountryIBAN validator 2020-12-03 16:47:45 +01:00
lion-input-iban.js feat: release inital public lion version 2019-04-26 10:37:57 +02:00
package.json Version Packages 2020-12-07 13:18:25 +00:00
README.md chore: allow array for IsNotCountryIBAN 2020-12-03 18:33:16 +01:00

Input IBAN

lion-input-iban component is based on the generic text input field. Its purpose is to provide a way for users to fill in an IBAN (International Bank Account Number).

import { html } from 'lit-html';
import { loadDefaultFeedbackMessages } from '@lion/validate-messages';
import { IsCountryIBAN, IsNotCountryIBAN } from './src/validators.js';

import './lion-input-iban.js';

export default {
  title: 'Forms/Input Iban',
};

loadDefaultFeedbackMessages();
export const main = () => {
  return html` <lion-input-iban label="Account" name="account"></lion-input-iban> `;
};

Features

  • Based on lion-input
  • Default label in different languages
  • Makes use of IBAN specific validate with corresponding error messages in different languages
    • IsIBAN (default)
    • IsCountryIBAN
  • Parses IBANs automatically
  • Formats IBANs automatically

How to use

Installation

npm i --save @lion/input-amount
import { LionInputIban } from '@lion/input-iban';
// or
import '@lion/input-amount/lion-input-amount.js';

Examples

Prefilled

export const prefilled = () => html`
  <lion-input-iban .modelValue=${'NL20INGB0001234567'} name="iban" label="IBAN"></lion-input-iban>
`;

Faulty Prefilled

export const faultyPrefilled = () => html`
  <lion-input-iban
    .modelValue=${'NL20INGB0001234567XXXX'}
    name="iban"
    label="IBAN"
  ></lion-input-iban>
`;

Country Restrictions

By default, we validate the input to ensure the IBAN is valid. To get the default feedback message for this default validator, use loadDefaultFeedbackMessages from @lion/form-core.

In the example below, we show how to use an additional validator that restricts the input-iban to IBANs from only certain countries.

export const countryRestrictions = () => html`
  <lion-input-iban
    .modelValue=${'DE89370400440532013000'}
    .validators=${[new IsCountryIBAN('NL')]}
    name="iban"
    label="IBAN"
  ></lion-input-iban>
  <br />
  <small>Demo instructions: you can use NL20 INGB 0001 2345 67</small>
`;

Blacklisted Country

By default, we validate the input to ensure the IBAN is valid. To get the default feedback message for this default validator, use loadDefaultFeedbackMessages from @lion/form-core.

In the example below, we show how to use an additional validator that blocks IBANs from certain countries.

You can pass a single string value, or an array of strings.

export const blacklistedCountry = () => html`
  <lion-input-iban
    .modelValue=${'DE89370400440532013000'}
    .validators=${[new IsNotCountryIBAN(['RO', 'NL'])]}
    name="iban"
    label="IBAN"
  ></lion-input-iban>
  <br />
  <small
    >Demo instructions: Try <code>RO 89 RZBR 6997 3728 4864 5577</code> and watch it fail</small
  >
`;