0.0.6-SNAPSHOT-2 • Published 6 years ago

@von-development-studio/form-validation v0.0.6-SNAPSHOT-2

Weekly downloads
-
License
ISC
Repository
gitlab
Last release
6 years ago

Directive: form-validation

Custom form validation for Angular and PrimeNG.

Read this in other language: Spanish

Requirements

Installing

  1. Add NPM package into your project:

    npm install @von-development-studio/form-validation --save
  2. Add FormValidationModule into imports section

    import { FormValidationModule } from '@von-development-studio/form-validation';
    
    ...
    
    @NgModule({
      imports: [
        ...
        FormValidationModule,
        ...
      ]
    })
    export class AppModule { }

Usage

  1. Add attribute (validate) (instead of submit or ngSubmit) & novalidate in form tag:

    <form (validate)="login()" novalidate>
  2. In each field you want to add a validation:

    <input validation type="text" name="username" [(ngModel)]="login.username" required />
  1. Your button type should be submit:

    <button type="submit">Login</button>

Directives

  • required: Checks null value

    <input name="requiredField" [(ngModel)]="value" required validation />
  • equalTo: Checks current [(ngModel)] value with parameter in [equalTo]

    <input name="equalToField" [(ngModel)]="value1" [equalTo]="value2" validation />
  • equalToElement: Checks current [(ngModel)] value with element receive in [equalToElement]

    <input #field1 name="field1" [(ngModel)]="value1" required validation />
    <input name="field2" [(ngModel)]="value2" [equalToElement]="field1" validation />

Default validation messages

  • requiredMessage: The field ${name} is required, needs name attribute in HTML element

  • equalToSimpleMessage: The field ${field1} is not equal, needs name attribute in HTML element. Valid with equalTo directive

  • equalToComplexMessage: The field ${field1} is not equal to ${field2}, needs name attribute in HTML element. Valid with equalToElement directive

Mensajes personalizados

  • equalToMessage: This message will replace equalToSimpleMessage & equalToComplexMessage
By Von Development Studio
0.0.6-SNAPSHOT-2

6 years ago

0.0.6-SNAPSHOT-1

6 years ago

0.0.6-SNAPSHOT-0

6 years ago

0.0.6-SNAPSHOT

6 years ago

0.0.5

7 years ago

0.0.4-SNAPSHOT-9

7 years ago

0.0.4-SNAPSHOT-7

7 years ago

0.0.4-SNAPSHOT-6

7 years ago

0.0.4-SNAPSHOT-5

7 years ago

0.0.4-SNAPSHOT-4

7 years ago

0.0.4-SNAPSHOT-3

7 years ago

0.0.4-SNAPSHOT-2

7 years ago

0.0.4-SNAPSHOT-1

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.3-SNAPSHOT-3

7 years ago

0.0.3-SNAPSHOT-2

7 years ago

0.0.3-SNAPSHOT-1

7 years ago

0.0.3-SNAPSHOT

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago