Files
trezor-suite/packages/validation
Daniel Suchý a446583d58 chore(ci): Nx for github validations (#6095)
* chore(ci): Nx for github validations

* chore: tune config

* chore: eslint scripts faster and unified settings

* chore: check formatting using nx

* chore: read-only NX token
2022-08-25 18:51:12 +02:00
..
2022-07-13 10:59:59 +02:00

@trezor/validation

This package extends yup validation library with custom methods, messages and types. Whenever yup is used in Suite, it should be imported from here rather than directly from yup. Using ValidationSchema enables type check on the schema object.

Usage

import { ValidationSchema, yup } from '@trezor/validation';

// providing a type for the schema object for type safety
type MySchema = {
    myField: string;
};

const mySchema =
    yup.object <
    ValidationSchema<MySchema>({
        myField: yup
            .string() // standard yup validation
            .isAscii(), // custom validation including a custom message
    });