2.1.1 • Published 2 years ago

@phoenixreisen/form v2.1.1

Weekly downloads
28
License
MIT
Repository
github
Last release
2 years ago

Phoenix Reisen Formular Modul

Wiederverwendbarer Stuff zum vereinfachten Handling reaktiver Formulare - instant Validierung für verschiedene Feldtypen, Validierung für gesamtes Formular, Prüfung auf Browser-Support für Datepicker, und anderes.

Installation

npm install --save @phoenixreisen/form

Anwendung (Beispiel)

Konfig & Types importieren:

import {DateConfig, ValidationTypes, UserTypes} from '@phoenixreisen/form';

Felder importieren:

import {text, int, email, bookingnr} from '@phoenixreisen/form';

Funktionen importieren:

import {isValidInput, isDateSupported} from '@phoenixreisen/form';

Formular deklarieren: (Parameter-Signatur der einzelnen Felder beachten, weitere Beispiele in Ordner spec)

const form = {
    prename: text(true, input => {      // Text
        console.log('hooked')
        input = input.trim();
        return input;
    }),
    surname: text(),                    // Text
    age: int(false),                    // optionales Feld, Int Validierung
    bookingnr: bookingnr()              // Validierung auf gültige Buchungsnr.
};

Form-Feld an ein bestimmtes HTML-Feld binden:

<input
    type="text"
    placeholder="Beispiel..."
    value={form.surname.value()}
    oninput={e => form.surname.validate(e.target.value)}
/>
{form.surname.complaint && form.surname.complaint === ValidationTypes.empty ?
    <div class="alert alert--warning">
        Bitte ausfüllen
    </div>
}

Bei Submit alles validieren lassen:

function submit(form) {
    if(!Form.isValidInput(form)) {
        // bei invaliden Feldern wurde property "complaint"
        // auf true oder einen der ValidationTypes (string) gesetzt.
        return;
    }
    // code...
}

Deployment

[npm install]                       # Abhängigkeiten installieren
npm version [major|minor|patch]     # increase version x.x.x => major.minor.patch
npm publish                         # upload to npm
git push
2.1.1

2 years ago

2.1.0

2 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.5.0

3 years ago

1.4.0

3 years ago

1.3.3

3 years ago

1.3.2

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.2

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.0

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.12

4 years ago

0.0.11

4 years ago

0.0.10

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago