Getting started

Decorators

Components

Directive

Validators

Custom Validators

Error messages

Customise\Override Error Messages

Description

The ValidationSchema class is a utility class that provides a static method create() to generate a validation schema based on the properties and validation rules of a form. The validation schema is an array of GVItemConfig objects, each representing a form control's configuration, including its name, type, and validation rules.

Static Method

create(): GVItemConfig[]

Description: The create() static method is used to generate a validation schema for form controls. It returns an array of GVItemConfig objects, each representing a form control's configuration and validation rules.

Returns:

Usage:

typescriptCopy code
import { GVItemConfig, FormControlType } from '@releasium/ngx-grand-validator';

export class ValidationSchema {
  static create(): GVItemConfig[] {
    // Schema generation logic here
  }
}

Example:

typescriptCopy code
import { GVItemConfig, FormControlType } from '@releasium/ngx-grand-validator';

export class ValidationSchema {
  static create(): GVItemConfig[] {
    return [
      {
        name: 'firstName',
        type: FormControlType.CONTROL,
        validation: [
          {
            available: true,
            rules: {
              required: {
                value: true,
                msg: 'mp.payment-form.checking-form.routing-number.error.pattern'
              }
            }
          }
        ]
      },
      {
        name: 'lastName',
        type: FormControlType.CONTROL,
        validation: [
          {
            available: true,
            rules: {
              required: true,
            }
          }
        ]
      },
      {
        name: 'age',
        type: FormControlType.CONTROL,
        validation: [
          {
            available: true,
            rules: {
              required: true,
            }
          }
        ]
      },
    ];
  }
}

GVItemConfig Interface