1.0.3 • Published 1 year ago

fieldscript v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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",
1.0.3

1 year ago