joi4j

0.1.2 • Public • Published

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).

Readme

Keywords

none

Package Sidebar

Install

npm i joi4j

Weekly Downloads

6

Version

0.1.2

License

MIT

Unpacked Size

357 kB

Total Files

16

Last publish

Collaborators

  • bboure