Skip to content

Support for custom locale validation messages #310

Open
@neil-coutinho

Description

@neil-coutinho

Issue type

I'm submitting a (check one):
[ ] Bug report
[x] Feature request
[ ] Regression (something that used to work, but stopped working in a newer version)
[x] Support request
[ ] Documentation issue or request

Prerequisites

Before posting, make sure you do the following (check all):
[x] Confirm you are using the latest versions of all necessary packages (or if not, explain why not)
[x] Search GitHub for a similar issue or PR
[x] If submitting a Support request, also search Stack Overflow for similar issues
Note: Please cross-post GitHub support requests to Stack Overflow, and include a link in your GitHub issue to your Stack Overflow question. We do currently respond to support requests on GitHub, but we eventually expect to stop, and will then refer all support questions exclusively to Stack Overflow.

Current behavior

Currently, we have support English and French validation messages. In addition, we can provide validation messages by using one of the 3 available methods i.e.

  • String: A plain text message, which is always the same.
  • String template: A text message that includes Angular template-style {{variables}}, which will be be replaced with values from the returned error object.
  • Function: A JavaScript function which accepts the error object as input, and returns a string error message.

Is there an option where in my custom widget component I can subscribe to a language change event and trigger and update to update the layoutNode's validationMessages?

Trying to support Spanish and a few other custom languages in my forms

 this.languageSwitch.currentLang
        .subscribe(data => {

         this.options.validationMessages.required = 'CUSTOM_LANGUAGE_STRING

      });

Expected behavior

IMPORTANT: How can we reproduce your problem?

Environment

OS name & version:
Browser name & version:
Angular version:
Angular JSON Schema Form version(s):
Other relevant software or packages:

Any other relevant information

In my custom widget I am subscribed to a language Subject Observable. When the SUBJECT emit's a new value I want to change the validation message to a custom string based on the emitted language code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions