Socket
Socket
Sign inDemoInstall

@open-formulieren/types

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@open-formulieren/types - npm Package Compare versions

Comparing version 0.22.0 to 0.23.0

53

lib/formio/validation.d.ts

@@ -0,1 +1,45 @@

/**
* @file Types related to (client-side) formio validation and their error message overrides.
*
* This module is responsible for defining:
* - the available validation constraints
* - the corresponding (translatable) error codes.
*
* The `ValidateOptions` interface (which is extended/restricted for our needs) defines
* the available validation constraints that can be used by a component. By using our custom
* `OFValidateOptions` interface, one can define the available `validate` keys:
*
* ```ts
* type TimeComponentSchema = SomeBaseComponent & {validate: OFValidateOptions<'min' | 'max'>};
*
* // a component with such a type can be defined as:
* const timeComponent: TimeComponentSchema = {
* validate: {
* minTime: '11:00',
* maxTime: '13:00',
* }
* }
* ```
*
* Each validation constraint key can provide possible error keys if validation fails. This mapping
* of constraint keys (e.g. `minTime`, `maxTime`) to the error keys is defined in `VALIDATOR_TO_ERROR_KEY`.
*
* This can be used when defining the error messages:
*
* ```ts
* type TimeComponentSchema = SomeBaseComponent & {errors: ComponentErrors<ComponentErrorKeys<'minTime' | 'maxTime'>>};
*
* // a component with such a type can be defined as:
* const numberComponent: NumberComponentSchema = {
* errors: {
* minTime: 'Time should be greater than ...',
* maxTime: 'Time should be lower than ...',
* invalid_time: 'Invalid time', // Both `minTime` and `maxTime` provides the `invalid_time` error key.
* }
* }
* ```
*
* NOTE: In some places of the file, we refer to the validation constraint keys as "validator names". Those should
* *NOT* be confused with validator keys used in the SDK (e.g. `timeMinMax`).
*/
import { ValidateOptions } from 'formiojs';

@@ -10,6 +54,3 @@ declare module 'formiojs' {

}
/**
* Types related to (client-side) formio validation and their error message overrides.
*/
export type BaseErrorKeys = 'required' | 'min' | 'max' | 'maxLength' | 'invalid_email' | 'pattern' | 'minDate' | 'maxDate' | 'customMessage' | 'minSelectedCount' | 'maxSelectedCount' | 'minTime' | 'maxTime' | 'invalid_time';
export type BaseErrorKeys = 'required' | 'min' | 'max' | 'maxLength' | 'invalid_email' | 'pattern' | 'minDate' | 'maxDate' | 'customMessage' | 'minSelectedCount' | 'maxSelectedCount' | 'invalid_date' | 'minTime' | 'maxTime' | 'invalid_time' | 'invalid_datetime';
export type ComponentErrors<Keys extends BaseErrorKeys = BaseErrorKeys> = {

@@ -30,4 +71,4 @@ [K in Keys]?: string;

readonly maxSelectedCount: "maxSelectedCount";
readonly minDate: "minDate";
readonly maxDate: "maxDate";
readonly minDate: "minDate" | "invalid_date" | "invalid_datetime";
readonly maxDate: "maxDate" | "invalid_date" | "invalid_datetime";
readonly minTime: "minTime" | "invalid_time";

@@ -34,0 +75,0 @@ readonly maxTime: "maxTime" | "invalid_time";

2

package.json
{
"name": "@open-formulieren/types",
"version": "0.22.0",
"version": "0.23.0",
"description": "Typescript type definitions for Open Forms' Form.io extensions",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc