fieldscript

1.0.3 • Public • Published

FieldScript: Protect Your APIs with Type Safety in Pure JavaScript.

  • 💜 Protect Your Apis
  • 💜 Pure JavaScript Type Safety
  • 💜 Assign Variables

A https://hub.codehubby.com package to easily Protect Your APIs by Easily Enforcing Type Safety in Pure JavaScript. Use .check({}) to batch check with variable names in error messages or use the individual methods such as stringField(), intField() and booleanField().

index.js:

import * as FieldScript from './FieldScript.js';
import { stringField, intField, booleanField, objectField, listField } from './FieldScript.js';

let noteObj = {title:'test','code':'test2',order:234} // remove or edit property to test

const { title,code } = FieldScript.check({
  title: () => FieldScript.stringField(noteObj.title),
  code: () => FieldScript.stringField(noteObj.code),
  order: () => FieldScript.intField(noteObj.order),
})

console.log({title, noteObj})

Quick Tip to Use Import / ES6 with NodeJS:

Add this to your package.json file

  "type":"module",

Readme

Keywords

none

Package Sidebar

Install

npm i fieldscript

Weekly Downloads

1

Version

1.0.3

License

ISC

Unpacked Size

6.53 kB

Total Files

3

Last publish

Collaborators

  • neil-yoga