Skip to content
Adds Joi validation for Neo4j data types
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitignore
README.md
date.js
date.test.js
datetime.test.js
index.js
jest.config.js
localdatetime.test.js
package.json
point.test.js
spatial.js
utils.js
yarn-error.log
yarn.lock

README.md

This plugin for Joi adds validation for Neo4j (Cypher) types that are not mapped to native javascript, as explained here

Supported types

Type Supported
Date
Time
LocalTime
DateTime
LocalDateTime
Duration
Point

Install

yarn install joi4j --save
# or
npm install joi4j

How to use

const joi4j = require('joi4j');
const validator = joi.extend(joi4j);

validator.validate(
    "2019-01-01",
    validator.neo4jDate(),
    function (error, data) {

    }
);

Api Reference

neo4jDate - inherits from Any

Validates that the input is a correct Neo4j Date instance. If the validation convert option is on (enabled by default), a string or native javascript Date object will be converted to a Neo4j Date if specified.

Date's min, max, greater and less are also available.

neo4jDateTime - inherits from Any

Validates that the input is a correct Neo4j DateTime instance. If the validation convert option is on (enabled by default), a string or native javascript Date object will be converted to a Neo4j DateTime if specified.

Date's min, max, greater and less are also available.

neo4jLocalDateTime - inherits from Any

Validates that the input is a correct Neo4j LocalDateTime instance. If the validation convert option is on (enabled by default), a string or native javascript Date object will be converted to a Neo4j LocalDateTime if specified.

Date's min, max, greater and less are also available.

neo4jPoint - inherits from Any

Validates that the input is a correct Neo4j Point. If the validation convert option is on (enabled by default), a key-value pair object will be converted to a Neo4j Point if specified. If not provided, the srid will be assumed from the keys.

neo4jPoint.coordinates()

Validates that the point is a correct coordinates point (latitude, longitude [, height])

neo4jPoint.cartesian()

Validates that the point is a correct coordinates point (x, y [, z]).

neo4jPoint.is2d()

Validates that the point is a correct 2D point (no height or z is given).

neo4jPoint.is3d()

Validates that the point is a correct 2D point (either height or z is given).

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.