This plugin for Joi adds validation for Neo4j (Cypher) types that are not mapped to native javascript, as explained here
Type | Supported |
---|---|
Date | ✅ |
Time | ❌ |
LocalTime | ❌ |
DateTime | ✅ |
LocalDateTime | ✅ |
Duration | ❌ |
Point | ✅ |
yarn install joi4j --save
# or
npm install joi4j
const joi4j = require('joi4j');
const validator = joi.extend(joi4j);
validator.validate(
"2019-01-01",
validator.neo4jDate(),
function (error, data) {
}
);
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.
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.
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.
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.
Validates that the point is a correct coordinates point (latitude, longitude [, height])
Validates that the point is a correct coordinates point (x, y [, z])
.
Validates that the point is a correct 2D point (no height or z is given).
Validates that the point is a correct 2D point (either height or z is given).