@newskit-render/validation
    TypeScript icon, indicating that this package has built-in type declarations

    0.49.0 • Public • Published

    @newskit-render/validation

    A package for adding validation to my account.

    How to use:

    import initializeYupSchema, { OverrideYupSchemaType, } from '@newskit-render/validation'

    import \* as yup from 'yup'

    /_ Example of name validation override _/

    const nameValidation = yup.object().shape({
      firstName: yup.string().required('First Name is required overriden'),
      lastName: yup.string().required('Last Name is required overriden'),
    })
    

    /_ Pass your override schema to here, so it's delegated accordingly _/

    const overrideYupSchema: OverrideYupSchemaType = {
      name: nameValidation,
    }
    

    export default initializeYupSchema({overrideYupSchema})

    Initializing Options

    You can pass message templates, that will be used as the template of the required messages and wrong format messages.

    export default initializeYupSchema({
      overrideYupSchema: overrideYupSchema,
      options: {
        requiredMessage: "Please enter your ${field}",
        wrongFormatMessage : '${field} is wrong format'
      }
    })
    
    

    Yup testing documentation .

    Keywords

    none

    Install

    npm i @newskit-render/validation

    DownloadsWeekly Downloads

    422

    Version

    0.49.0

    License

    UNLICENSED

    Unpacked Size

    145 kB

    Total Files

    20

    Last publish

    Collaborators

    • newskit