Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The configuration of @ngx-validate/core cannot be overridden #4858

Closed
mehmet-erim opened this issue Jul 23, 2020 · 0 comments
Closed

The configuration of @ngx-validate/core cannot be overridden #4858

mehmet-erim opened this issue Jul 23, 2020 · 0 comments

Comments

@mehmet-erim
Copy link
Contributor

We use the @ngx-validate/core package for managing the validation messages of reactive forms automatically.

The NgxValidateCore module is imported to ThemeBasic but there is a problem here. We'll fix it to be able to override the default messages.

After this fix, you can define your own validation configuration in app.module.ts. If you like to override the configuration, you can import the NgxValidateCoreModule as like below:

// app.module.ts

@NgModule({
  imports: [
     // other imports

    ThemeBasicModule.forRoot(), // If you are a member of commercial, this should be ThemeLeptonModule.forRoot() instead.
    // make sure that the NgxValidateCoreModule is under the ThemeBasicModule
    // the configurations in ThemeBasicModule are as follows
    NgxValidateCoreModule.forRoot({
      targetSelector: '.form-group',
      blueprints: {
        creditCard: 'AbpValidation::ThisFieldIsNotAValidCreditCardNumber.',
        email: 'AbpValidation::ThisFieldIsNotAValidEmailAddress.',
        invalid: 'AbpValidation::ThisFieldIsNotValid.',
        max: 'AbpValidation::ThisFieldMustBeBetween{0}And{1}[{{ min }},{{ max }}]',
        maxlength:
          'AbpValidation::ThisFieldMustBeAStringOrArrayTypeWithAMaximumLengthOf{0}[{{ requiredLength }}]',
        min: 'AbpValidation::ThisFieldMustBeBetween{0}And{1}[{{ min }},{{ max }}]',
        minlength:
          'AbpValidation::ThisFieldMustBeAStringOrArrayTypeWithAMinimumLengthOf{0}[{{ requiredLength }}]',
        ngbDate: 'AbpValidation::ThisFieldIsNotValid.',
        passwordMismatch: 'AbpIdentity::Identity.PasswordConfirmationFailed',
        range: 'AbpValidation::ThisFieldMustBeBetween{0}And{1}[{{ min }},{{ max }}]',
        required: 'AbpValidation::ThisFieldIsRequired.',
        url: 'AbpValidation::ThisFieldIsNotAValidFullyQualifiedHttpHttpsOrFtpUrl',
      },
      errorTemplate: ValidationErrorComponent,
    }),
  ],
  // ...
})
export class AppModule {}
@mehmet-erim mehmet-erim added this to the 3.1 milestone Jul 23, 2020
@mehmet-erim mehmet-erim self-assigned this Jul 23, 2020
@mehmet-erim mehmet-erim changed the title The validation messages of @ngx-validate/core cannot be overridden The configuration of @ngx-validate/core cannot be overridden Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant