Neutron Polarization Manipulator

    schemr

    1.0.0 • Public • Published

    📃 Schemr

    Open Source Love Open Source Love PRs Welcome

    The Ultimate Tiny schema validation package.

    Getting Started

    npm install --save schemr
    

    Usage

    You can find a working example in tester.js.

    const { Schemr, check } = require('schemr');
     
    const testSchema = new Schemr('human-being', {
      name: Schemr.field,
      age: Schemr.field,
      job: Schemr.field,
    });
     
    console.log(testSchema.getName());
    //=> human-being
    console.log(testSchema.getFields());
    //=> { name: 'SchemrField', age: 'SchemrField', job: 'SchemrField' }
    console.log(testSchema.toJSON());
    /*=>
    {
        "name": "human-being",
        "fields": {
            "name": "SchemrField",
            "age": "SchemrField",
            "job": "SchemrField"
        }
    }
    */
     
    const testData = {
      name: 'Mark',
      extraFieldForNoReason: false,
    };
     
    const checkedObject = check(testSchema, testData);
    console.log(checkedObject);
    //=> { name: 'Mark', age: 21, job: undefined }
     
    const checkedObject2 = check(testSchema, testData, {
      replaceEmptyFieldsWith: 'unfilled',
    });
     
    console.log(checkedObject2);
    //=> { name: 'Mark', age: 'unfilled', job: 'unfilled' }

    License

    • MIT

    Roadmap

    TODO

    Install

    npm i schemr

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    5.32 kB

    Total Files

    5

    Last publish

    Collaborators

    • molnarmark