@flatfile/plugin-constraints
TypeScript icon, indicating that this package has built-in type declarations

1.1.8 • Public • Published

@flatfile/plugin-constraints

This plugin introduces the ability to register external constraints for blueprint.

Usage

listener.use(
  externalConstraint('length', (value, key, { config, record }) => {
    if (value.length > config.max) {
      record.addError(key, `Text must be under ${config.max} characters`)
      // alternatively throw the error
    }
  })
)
// blueprint fields
[
  {
    key: 'name',
    type: 'string',
    constraints: [
      { type: 'external', validator: 'length', config: { max: 100 } }
    ]
  },
  {
    key: 'age',
    type: 'number',
  }
]

Readme

Keywords

none

Package Sidebar

Install

npm i @flatfile/plugin-constraints

Weekly Downloads

228

Version

1.1.8

License

ISC

Unpacked Size

4.33 MB

Total Files

7

Last publish

Collaborators

  • sambarrowclough
  • carlbrugger
  • hansjhoffman
  • haleymt
  • mmccooyyy
  • ahollenbeck
  • maerf0x0
  • rjhyde
  • mpoythress
  • flatderek
  • ashleygmulligan
  • alnoor
  • flatfilecolin
  • bigcountrycrane
  • flatfileinfra
  • bangarang
  • madmandrit
  • roberto-alcantara-ffile
  • mairechew
  • jmmander
  • srmotter
  • driscollrp
  • sarocu
  • dboskovic
  • brentkulwicki
  • nate.ferrero
  • jaredwalters