@epistemology-factory/crocks-web
Advanced tools
Comparing version 0.2.6 to 0.2.7
{ | ||
"name": "@epistemology-factory/crocks-web", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "Functions to help write web applications with crocks", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -5,2 +5,4 @@ "use strict"; | ||
IS_DEFINED: "is-defined", | ||
IS_ISO_DATE: "is-iso-date", | ||
IS_OBJECT: "is-object", | ||
IS_STRING: "is-string", | ||
@@ -11,2 +13,4 @@ } | ||
[CONSTRAINTS.IS_DEFINED]: "should not be null or undefined", | ||
[CONSTRAINTS.IS_ISO_DATE]: "should be an ISO date", | ||
[CONSTRAINTS.IS_OBJECT]: "must be an object", | ||
[CONSTRAINTS.IS_STRING]: "must be a string", | ||
@@ -13,0 +17,0 @@ } |
@@ -19,2 +19,6 @@ "use strict"; | ||
const { makeValidator } = require("./validator"); | ||
const { validationFailure } = require("../validation-failure"); | ||
const { CONSTRAINTS, DEFAULT_MESSAGES } = require("./constraints"); | ||
/** | ||
@@ -27,2 +31,11 @@ * Schema :: { | ||
// isObject :: [ String ] -> a -> Result ValidationFailure a | ||
const isObject = makeValidator( | ||
require("crocks/predicates/isObject"), | ||
validationFailure( | ||
CONSTRAINTS.IS_OBJECT, | ||
DEFAULT_MESSAGES[CONSTRAINTS.IS_OBJECT] | ||
) | ||
) | ||
/** | ||
@@ -58,3 +71,4 @@ * Allows an object to validated against a schema | ||
module.exports = { | ||
isObject, | ||
isSchemaValid | ||
} |
"use strict"; | ||
const curry = require("crocks/helpers/curry"); | ||
const { makeValidator } = require("./validator"); | ||
@@ -7,2 +9,14 @@ const { validationFailure } = require("../validation-failure"); | ||
// matchesRegex :: RegExp -> String -> Boolean | ||
const matchesRegex = curry((regexp, str) => regexp.test(str)) | ||
// isISODate :: [ String ] -> a -> Result ValidationFailure a | ||
const isISODate = makeValidator( | ||
matchesRegex(/^\d{4}-\d{2}-\d{2}$/), | ||
validationFailure( | ||
CONSTRAINTS.IS_ISO_DATE, | ||
DEFAULT_MESSAGES[CONSTRAINTS.IS_ISO_DATE] | ||
) | ||
); | ||
// isString :: [ String ] -> a -> Result ValidationFailure a | ||
@@ -18,3 +32,4 @@ const isString = makeValidator( | ||
module.exports = { | ||
isISODate, | ||
isString | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27353
747