šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

meteor-simple-schema-transform

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meteor-simple-schema-transform

Build validate functions for redux-form from Meteor SimpleSchema

1.0.5
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
Ā 
Created
Source

meteor-simple-schema-transform

Transform Meteor SimpleSchema objects into other objects and functions for use with a variety of form engines, validators, etc.

SST (SimpleSchemaTransform)

A helper to turn a Meteor SimpleSchema into a variety of translations and transformations, for use with any other form builder, validator, submitter, etc.

The goal is to make SimpleSchema a portable source, for other libraries.

Status

This is a very early idea project. Take a look at this forum thread

Also checkout the excellent uniforms project for a more complete solution for forms (though more tied to Meteor).

Install

npm i --save meteor-simple-schema-transform

Usage

There are various parts you may want to use. Include only those tools you need.

Missing a tool/translation? (add it and submit a PR)

SST.buildClean

Build SimpleSchema into a value cleanup function - clean values object based on schema

// MyContainer
import { Meteor } from 'meteor/meteor';
import { createContainer } from 'meteor/react-meteor-data';
import { MyPage } from '../pages/MyPage';

import SST from 'meteor-simple-schema-transform';

const mySchema = new SimpleSchema({
  name: {
    label: "Friendly Name",
    type: String,
    min: 3,
    max: 30,
  }
});

const cleaner = SST.buildClean(mySchema);

export default createContainer(({ params }) => {
  // ....
  saveData (data) {
    Meteor.call('myMethod', cleaner(data), (err) => {
      if (err) console.error('Got Error on saveData', err);
    });
  }
  return {
    saveData
  }
}, MyPage);

SST.forReduxForm.buildValidate

Build SimpleSchema into a validate function for use with ReduxForm

// MyContainer
import { Meteor } from 'meteor/meteor';
import { createContainer } from 'meteor/react-meteor-data';
import { MyPage } from '../pages/MyPage';

import SST from 'meteor-simple-schema-transform';

const mySchema = new SimpleSchema({
  name: {
    label: "Friendly Name",
    type: String,
    min: 3,
    max: 30,
  }
});

const cleaner = SST.buildClean(mySchema);
const validate = SST.forReduxForm.buildValidate(mySchema);

export default createContainer(({ params }) => {
  // ....
  saveData (data) {
    Meteor.call('myMethod', cleaner(data), (err) => {
      if (err) console.error('Got Error on saveData', err);
    });
  }
  return {
    saveData,
    validate
  }
}, MyPage);

Roadmap

  • Proof of concept
  • other easy schema validate variations
  • other easy schema transformations

FAQs

Package last updated on 12 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts