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

another-json-schema

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

another-json-schema - npm Package Compare versions

Comparing version 3.8.1 to 3.8.2

4

changelog.md

@@ -0,1 +1,5 @@

## 3.8.2/2018-01-17
- add `.length` helper
## 3.8.1/2018-01-10

@@ -2,0 +6,0 @@

@@ -12,2 +12,13 @@ const validator = require('validator')

/*
* String
*/
exports.length = function (actual, expected, key, parent) {
if (Array.isArray(expected)) {
const len = actual.length
return len >= expected[0] && len <= expected[1]
}
return actual.length === expected
}
// return true|false

@@ -14,0 +25,0 @@ /*

2

package.json
{
"name": "another-json-schema",
"version": "3.8.1",
"version": "3.8.2",
"description": "Another JSON Schema, simple & flexible & intuitive.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -151,2 +151,28 @@ const AJS = require('..')

it('.length', function () {
const stringSchema = AJS('stringSchema', { type: 'string', length: 1 })
assert.deepEqual(stringSchema.validate('a'), { valid: true, error: null, result: 'a' })
assert.deepEqual(stringSchema.validate('hehe'), { valid: false,
error:
{
validator: 'length',
path: '$',
actual: 'hehe',
expected: { type: 'string', length: 1 },
schema: 'stringSchema' },
result: 'hehe' })
const stringSchema2 = AJS('stringSchema2', { type: 'string', length: [1, 2] })
assert.deepEqual(stringSchema2.validate('a'), { valid: true, error: null, result: 'a' })
assert.deepEqual(stringSchema2.validate('hehe'), { valid: false,
error:
{
validator: 'length',
path: '$',
actual: 'hehe',
expected: { type: 'string', length: [1, 2] },
schema: 'stringSchema2' },
result: 'hehe' })
})
it('.gt', function () {

@@ -153,0 +179,0 @@ const schema = AJS('numberSchema', { type: 'number', gt: 0 })

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