Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mschema

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mschema - npm Package Compare versions

Comparing version 0.5.3 to 0.5.4

.travis.yml

34

index.js

@@ -18,5 +18,13 @@ var mschema = {};

return true;
},
"file": function (val) {
// TODO: add binary file detection
return true;
}
};
mschema.define = function (_schema) {
return new Schema(_schema);
};
var validate = mschema.validate = function (_data, _schema, options) {

@@ -111,4 +119,10 @@

if (typeof property.regex === 'object') {
var re = property.regex
var result = re.exec(value);
var re = property.regex,
result;
if (property.required === false && value.length === 0) {
return;
}
result = re.exec(value);
if (result === null) {

@@ -253,3 +267,2 @@ errors.push({

// create a clone of the schema so the original schema passed is not modifed by _parse()

@@ -259,4 +272,4 @@ var schemaCopy = {};

// if the incoming data is not an object, create a single key object to represent it
if (typeof _data !== "object") {
// if the incoming data is not an object or function, assume its a single value and create a single keyed object to represent it
if (typeof _data !== "object" && typeof _data !== 'function') {
_data = {

@@ -394,2 +407,13 @@ key: _data

function Schema (_schema) {
if (!(this instanceof Schema)) {
return new Schema(_schema);
}
this._schema = _schema;
}
Schema.prototype.validate = function (_data, options) {
return mschema.validate(_data, this._schema, options);
};
module['exports'] = mschema;

2

package.json
{
"name": "mschema",
"version": "0.5.3",
"version": "0.5.4",
"keywords": ["schema", "mschema", "validator", "json", "json-schema"],

@@ -5,0 +5,0 @@ "description": "A schema language for defining the structure of JSON data",

# mschema
<img src="https://travis-ci.org/mschema/mschema.svg?branch=master"/>
A concise schema language for describing the structure of JSON data

@@ -4,0 +6,0 @@

@@ -56,2 +56,22 @@ var tap = require("tap"),

});
});
test("mschema.validate - empty value - constrained property - string - regex - required false", function (t) {
var user = {
"name": {
"type": "string",
"regex": /^[\w|\-|\.]+$/,
"required": false
}
};
var data = { "name": "" };
var result = mschema.validate(data, user);
t.equal(result.valid, true);
t.ok(result, "data is valid");
t.end();
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc