Lemoncode / lcFormValidation

Javascript based form validation library, third party library / framework agnostic.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alloow adding multiple field validation in a single method "AddFieldValidations"

brauliodiez opened this issue · comments

Whe a field include several validation it's a pain in the neck having to go repeating "AddFieldValidation", it would be a good idea to add a "AddFieldValidations" this method would accept as second prameter an array of objects.

Method signature (pseudocode):

class ValidationDefinition {
    handler : function();
    // later on it will include an addional field, called customArgs, this will let us define additional validation
   // info, a regex validator where we express the regEx in a custom arg, or a repeat password where
  // inform the Id of the password field to check against of
}

addFieldValidations(fieldName : string, validations : Array<ValidationDefinition>) : validationEngine

Usage:

   this._validationEngine.addFieldValidations('email',
                                               [
                                                 {handler: requiredValidationHandler},
                                                 {handler: emailValidationHandler}
                                               ]
                                            );

More info about this issuues: affected module:

./lib/src/validationEngine.ts

Methods to add (s):

addFieldValidation --> addFieldValidations
addFieldValidationAsync --> addFielValidationAsync
addFormValidation --> addFormValidations

Where to add unit tests

./lib/src/spec/validationEngine.spec.ts
./lib/src/spec/validationEngine.singleField.spec.ts
./lib/src/spec/validationEngine.singleForm.spec.ts