schm-computed

Adds computed parameters to schm schemas

Usage no npm install needed!

<script type="module">
  import schmComputed from 'https://cdn.skypack.dev/schm-computed';
</script>

README

schm-computed

NPM version

Adds computed parameters to schm schemas.

Install

$ npm install --save schm-computed

Usage

const schema = require('schm')
const computed = require('schm-computed')

const userSchema = schema({
  firstName: String,
  lastName: String,
}, computed({
  fullName: values => `${values.firstName} ${values.lastName}`,
}))

userSchema.parse({
  firstName: 'Diego',
  lastName: 'Haz'
})

Output:

{
  firstName: 'Diego',
  lastName: 'Haz',
  fullName: 'Diego Haz'
}

API

Table of Contents

computed

Add computed parameters to schema.

Parameters

License

MIT © Diego Haz