🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@comparaonline/ui-form-errors

Package Overview
Dependencies
Maintainers
12
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@comparaonline/ui-form-errors

## Installation

3.70.0
latest
npm
Version published
Maintainers
12
Created
Source

@comparaonline/ui-form-errors

Installation

yarn add @comparaonline/ui-form-errors

Usage

This package exposes a ErrorMessages context using ErrorMessageProvider and ErrorMessagesConsumer. A utility called replacer can be used to use templates that follow this convention

'The min value is {{minValue}} and the maxValue is {{maxValue}}'

... in your ErrorMessagesConsumer.

ErrorMessagesProvider

import { ErrorMessagesProvider } from '@comparaonline/ui-form-errors';

interface ErrorMessages = {
  [errorCode: string]: string
}

const errorMessages: ErrorMessages = {
  required: 'This field is required',
  outOfRange: 'The min value is {{minValue}} and the maxValue is {{maxValue}}'
}

<ErrorMessagesProvider value={{ errorMessages }}>
  ...
</ErrorMessagesProvider>

ErrorMessagesConsumer

<ErrorMessagesConsumer>
  {({ errorMessages }) => ()}
</ErrorMessagesConsumer>

FAQs

Package last updated on 29 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts