Form Validator
Simple package for easy form validation.
Installation
npm install formvalidator
or simply download and "require" this repository.
Usage
const FormValidator = ; const myForm = settings;
Sample settings
fieldId: 'ammount' fieldValue: '0' validation: 'isEmpty' 'isInteger' valid: true isRequired: true fieldId: 'phone' fieldValue: '123456' validation: 'isEmpty' 'isInteger' valid: true isRequired: true fieldId: 'notes' fieldValue: '' validation: 'isEmpty' 'isLongEnough' valid: true isRequired: false fieldId: 'email' fieldValue: '111@gmail.com' validation: 'isEmpty' 'isEmail' valid: true isRequired: true fieldId: 'nip' fieldValue: '538-317-76-23' validation: 'isEmpty' 'isNip' valid: true isRequired: true fieldId: 'postcode' fieldValue: '11-000' validation: 'isEmpty' 'isPostCode' valid: true isRequired: true ;
Available Methods
- FormValidator:
;
Checks if all required fields are valid without validating them.
;
Validates all form fields and runs .checkForm().
;
Returns a form field Object that was created using settings.
- FormField
Validates the field using validation functions provided in settings.
;
After setting new property value, .validate() will be run.
;
Available validation functions
;;;; //at the moment package only checks default length which is 10. TO DO;;;
TO DO
- Validation functions api
- Passing more than one arguments to validation functions