New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

async-validate

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-validate - npm Package Compare versions

Comparing version 0.4.7 to 0.4.8

test/spec/array-values.js

8

doc/readme/guide.md

@@ -78,2 +78,10 @@ ## Guide

#### Values
Used with the `array` type as a shorthand for validating array values, may be an `object` or `array` containing validation rules.
When `values` is an object it is applied to all array elements in the source array otherwise each `values` entry is compared against each source array entry which allows mixed types to be used in arrays.
Note that `values` is expanded to `fields`, see [deep rules](#deep-rules).
#### Enumerable

@@ -80,0 +88,0 @@

25

lib/schema.js

@@ -228,4 +228,27 @@ var iterator = require('./iterator')

func(series, function(rule, callback) {
var validator = getValidationOptions(rule, options);
var validator = getValidationOptions(rule, options)
, len
, i;
if(rule.type === 'array' && typeof rule.values === 'object') {
len = Array.isArray(rule.values)
? rule.values.length : Array.isArray(rule.value)
? rule.value.length : 0;
if(len) {
rule.fields = {};
}
// object declaration applies to all array values
if(!Array.isArray(rule.values)) {
for(i = 0;i < len;i++) {
rule.fields[i] = rule.values;
}
}else{
for(i = 0;i < len;i++) {
rule.fields[i] = rule.values[i];
}
}
}
var deep = (rule.type === 'object' || rule.type === 'array')

@@ -232,0 +255,0 @@ && typeof(rule.fields) === 'object';

10

lib/validator.js

@@ -17,2 +17,3 @@ var plugin = require('zephyr')

}
// reason constants

@@ -44,3 +45,6 @@ this.reasons = Reason.reasons;

if(typeof this.rule.message === 'function') {
// TODO: allow calls to raise() and error() this would
// TODO: stack overflow right now
msg = this.rule.message.call(this, message, args);
}else{

@@ -200,3 +204,3 @@ msg = this.rule.message

this.reasons.type,
this.messages.types[type], rule.field, rule.type);
this.messages.types[type], this.field, rule.type);
}

@@ -207,3 +211,3 @@ // straight typeof check

this.reasons.type,
this.messages.types[type], rule.field, rule.type);
this.messages.types[type], this.field, rule.type);
}

@@ -261,2 +265,4 @@ }

Validator.prototype.format = format;
Validator.prototype.isRoot = isRoot;

@@ -263,0 +269,0 @@ Validator.prototype.shouldValidate = shouldValidate;

{
"name": "async-validate",
"description": "Asynchronous validation for object properties.",
"version": "0.4.7",
"version": "0.4.8",
"author": "muji <noop@xpm.io>",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -15,2 +15,3 @@ Table of Contents

* [Length](#length)
* [Values](#values)
* [Enumerable](#enumerable)

@@ -155,2 +156,10 @@ * [Date Format](#date-format)

#### Values
Used with the `array` type as a shorthand for validating array values, may be an `object` or `array` containing validation rules.
When `values` is an object it is applied to all array elements in the source array otherwise each `values` entry is compared against each source array entry which allows mixed types to be used in arrays.
Note that `values` is expanded to `fields`, see [deep rules](#deep-rules).
#### Enumerable

@@ -157,0 +166,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