Huge News!Announcing our $40M Series B led by Abstract Ventures.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.1.6 to 0.1.7

7

lib/messages.js

@@ -9,4 +9,7 @@ /**

whitespace: '%s cannot be empty',
dateformat: "%s date %s is invalid for format %s",
date: "%s date %s is invalid",
date: {
format: "%s date %s is invalid for format %s",
parse: "%s date could not be parsed, %s is invalid ",
invalid: "%s date %s is invalid"
},
types: {

@@ -13,0 +16,0 @@ string: '%s is not a %s',

@@ -17,10 +17,17 @@ var util = require('util');

var date = function(rule, value, source, errors, options) {
var dt = rule.format ? moment(value, rule.format) : moment(value);
if(!dt.isValid()) {
if(!rule.required
&& (value == undefined || value == "")) {
return false;
}
var dt = moment(value, rule.format);
if(!dt) {
errors.push(error(rule,
util.format(options.messages.date.parse, rule.field, value)));
}else if(!dt.isValid()) {
if(rule.format) {
errors.push(error(rule,
util.format(options.messages.dateformat, rule.field, value, rule.format)));
util.format(options.messages.date.format, rule.field, value, rule.format)));
}else{
errors.push(error(rule,
util.format(options.messages.date, rule.field, value)));
util.format(options.messages.date.invalid, rule.field, value)));
}

@@ -27,0 +34,0 @@ }

@@ -16,4 +16,5 @@ var rules = require('../rule');

var validate = rule.required
|| (!rule.required && source.hasOwnProperty(rule.field));
|| (!rule.required && source.hasOwnProperty(rule.field) && source[rule.field]);
if(validate) {
console.log("Validating date %s with value: %s", rule.field, value);
rules.required(rule, value, source, errors, options);

@@ -20,0 +21,0 @@ rules.pattern(rule, value, source, errors, options);

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

@@ -6,0 +6,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

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