Socket
Socket
Sign inDemoInstall

monastery-js

Package Overview
Dependencies
42
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.10.6 to 1.10.7

4

docs/rules.md

@@ -13,3 +13,3 @@ ---

required | boolean
type | string - 'string', 'boolean', 'number', 'integer', 'id', 'any', '[image](#image-type)'
type | string - 'string', 'boolean', 'number', 'integer', 'date', 'id', 'any', '[image](#image-type)'
isAfter | see validator.isAfter

@@ -33,4 +33,6 @@ isBefore | see validator.isBefore

*Dates are unix timestamps, we hope to support for other timestamp variations soon..*
### Image type
`type: 'image'` will be converted to `type: 'any'` upon initialisation without any image plugins. This type allows plugins to hook into field type. See the corresponding plugins for more details or [monastery's default image plugin](./image-plugin).

@@ -47,2 +47,13 @@ let id = require('monk').id

},
'isDate': {
message: 'Value was not a unix timestamp.',
tryParse: function(x) {
if (util.isString(x) && x.match(/^[\+-]?[0-9]+$/)) return x // keep string nums intact
return isNaN(parseInt(x))? x : parseInt(x)
},
fn: function(x) {
if (util.isString(x) && x.match(/^[\+-]?[0-9]+$/)) return true
return typeof x === 'number' && (parseInt(x) === x)
}
},
'isInteger': {

@@ -49,0 +60,0 @@ message: 'Value was not an integer.',

@@ -5,3 +5,3 @@ {

"author": "Ricky Boyce",
"version": "1.10.6",
"version": "1.10.7",
"license": "MIT",

@@ -8,0 +8,0 @@ "repository": "github:boycce/monastery",

@@ -6,2 +6,3 @@ module.exports = function(monastery, db) {

let user = db.model('user', { fields: {
date: { type: 'date' },
name: { type: 'string', required: true },

@@ -28,4 +29,12 @@ colors: [{ type: 'string' }],

// Type error (date)
await expect(user.validate({ name: 'a', date: 'fe' })).rejects.toContainEqual({
status: '400',
title: 'date',
detail: 'Value was not a unix timestamp.',
meta: { rule: 'isDate', model: 'user', field: 'date' }
})
// Type error (array)
await expect(user.validate({ colors: 1 })).rejects.toContainEqual({
await expect(user.validate({ name: 'a', colors: 1 })).rejects.toContainEqual({
status: '400',

@@ -38,3 +47,3 @@ title: 'colors',

// Type error (array)
await expect(user.validate({ colors: null })).rejects.toContainEqual({
await expect(user.validate({ name: 'a', colors: null })).rejects.toContainEqual({
status: '400',

@@ -47,3 +56,3 @@ title: 'colors',

// Type error (object)
await expect(user.validate({ animals: [] })).rejects.toContainEqual({
await expect(user.validate({ name: 'a', animals: [] })).rejects.toContainEqual({
status: '400',

@@ -56,3 +65,3 @@ title: 'animals',

// Type error (object)
await expect(user.validate({ animals: null })).rejects.toContainEqual({
await expect(user.validate({ name: 'a', animals: null })).rejects.toContainEqual({
status: '400',

@@ -59,0 +68,0 @@ title: 'animals',

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc