Gazebo_simulation-Frontend/node_modules/skema
Riddhi Dave f4870cd530 simulator page updates 2020-12-22 09:59:14 -05:00
..
lib React files 2020-12-21 10:29:31 -05:00
node_modules/async simulator page updates 2020-12-22 09:59:14 -05:00
test React files 2020-12-21 10:29:31 -05:00
.npmignore React files 2020-12-21 10:29:31 -05:00
.travis.yml React files 2020-12-21 10:29:31 -05:00
LICENSE-MIT React files 2020-12-21 10:29:31 -05:00
README.md React files 2020-12-21 10:29:31 -05:00
index.js React files 2020-12-21 10:29:31 -05:00
package.json simulator page updates 2020-12-22 09:59:14 -05:00

README.md

NPM version Build Status Dependency Status

skema

Skema is common abstract node.js methods for validatiors and setters.

Usage

npm install skema --save

skema(options)

var skema = require('skema');
var s = skema({
  rule: {
    validate: function(v){
      var done = this.async();
      remoteChecking(v, function(err){
        done(err);
      });
    },
    set: function(v){
      return v + 1;
    },
    get: function(v){
      return v - 1;
    }
  }
});
s.validate(1, function(err){
  console.log(err);
});
s.set(1, function(err, v){
  console.log(v); // 2
  s.get(v, function(err){
    console.log(v); // 1
  });
});

options.rule

  • validate: function(v)|RegExp|Array Could be an validate function, or a regular expression, or an array of them.
  • set: function(v)|Array.<function(v)>
  • get: function(v)|Array.<function(v)>

The this object of each of rule.validate, rule.set and rule.get has a method called async, we can use:

var done = this.async();

to turn the either one of the tree into an async method, as well as the familiar way of node.js.

.validate(value, [args], callback)

  • value
  • args Array= Extra arguments that will be passed into rule.validate for extension.
  • callback function(err)

.set(value, [args], callback)