get-yup-fields

1.0.0 • Public • Published

get-yup-fields

Get fields from a yup schema

npm i get-yup-fields

Usage

const yup = require('yup')
const getYupFields = require('get-yup-fields')

const schema = yup.object().shape({
  amount: yup.number().min(0.01).max(100).required(),
  choices: yup.string().oneOf(['A', 'B']).required()
})

console.log(getYupFields(schema)) /* => [
  {
    name: 'amount',
    type: 'number',
    required: true,
    default: undefined,
    nullable: false,
    min: 0.01,
    max: 100,
    more: null,
    less: null,
    whitelist: null
  },
  {
    name: 'choices',
    type: 'string',
    required: true,
    default: undefined,
    nullable: false,
    min: null,
    max: null,
    more: null,
    less: null,
    whitelist: [ 'A', 'B' ]
  }
] */

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i get-yup-fields

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

6.71 kB

Total Files

6

Last publish

Collaborators

  • lukks