Socket
Socket
Sign inDemoInstall

@comparaonline/ui-form-errors

Package Overview
Dependencies
13
Maintainers
11
Versions
47
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @comparaonline/ui-form-errors

## Installation


Version published
Weekly downloads
50
Maintainers
11
Install size
1.34 MB
Created
Weekly downloads
 

Readme

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

Last updated on 10 Nov 2021

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc