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

@smallwins/validate

Package Overview
Dependencies
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smallwins/validate - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

14

index.js

@@ -111,3 +111,7 @@ var isObject = require('lodash.isobject')

if (isNumAndUnderMin || lengthUnderMin || isCustom) {
errors.push(RangeError(k + ' below min with value ' + value + ' (min is ' + prop.min + ')'))
var msg = ''
msg += k + ' over max with value '
msg += lengthUnderMin? value.length : value
msg += ' (min is ' + prop.min + ')'
errors.push(RangeError(msg))
}

@@ -121,3 +125,3 @@ }

// String & Array: both respond to length
var lengthOverMax = (isString(value) || isArray(value)) && value.length < prop.max
var lengthOverMax = (isString(value) || isArray(value)) && value.length > prop.max
// Custom max found on a valid custom type

@@ -127,3 +131,7 @@ var isCustom = prop.type.max && !isError(prop.type(value)) && !prop.type.max(prop.max, value)

if (isNumAndOverMax || lengthOverMax || isCustom) {
errors.push(RangeError(k + ' over max with value ' + value + ' (max is ' + prop.max + ')'))
var msg = ''
msg += k + ' over max with value '
msg += lengthOverMax? value.length : value
msg += ' (max is ' + prop.max + ')'
errors.push(RangeError(msg))
}

@@ -130,0 +138,0 @@ }

{
"name": "@smallwins/validate",
"version": "3.1.1",
"version": "3.2.0",
"main": "index",

@@ -5,0 +5,0 @@ "scripts": {

@@ -36,6 +36,7 @@ [ ![Codeship Status for smallwins/validate](https://codeship.com/projects/e0e990b0-d826-0133-2fa3-6a1daaefbd5c/status?branch=master)](https://codeship.com/projects/143153)

- Thusly, primarily concerned with JSON value types: `Object`, `String`, `Number`, `Array` and `Boolean`
- Custom types are easily supported (see `./examples`)
- Custom types are easily supported
- Extra custom types bundled: `Email`, `ISO`, `DateRange` and `UUID`
- Designed to test keys and nested keys
- Optionally validate `required`
- Optionally validate `min` and `max` for `String`, `Number` and `Array` builtin types (and easily implement for custom types)
- Optionally validate `min` and `max` for `String`, `Number` and `Array` builtin types (and easily implement for custom types / see `DateRange` for an example)

@@ -42,0 +43,0 @@ ### things it does not do

var test = require('tape')
var validate = require('../')
var basics = require('../examples/basics')

@@ -19,1 +20,16 @@

})
test('max str', t=> {
t.plan(1)
var schema = {
maximal: {required:true, type:String, max:255}
}
var errors = validate({maximal:'lil'}, schema)
if (errors) {
t.fail(errors)
console.log(errors)
}
else {
t.ok(true, 'no errors')
}
})
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