mark-joi-rules
A collection of predefined Joi validation rules.
Usage
var MarkJoi = ;
Define a Joi Schema
var Joi = ;var MarkJoi = ; const joiSchema = Joiobject;
Validate it using Joi
let ret = Joi;
MarkJoi.user
user.username
rules:
- Must start with letter and contains only numbers and letters.
- Minimun is 4 characters and Maximum of 32 Characters
user.password
rules:
- Minimum of 8 characters and Maximum of 32 characters.
Extra
JoiSchemaValidator
Usage
MarkJoiSchema.validate()
Accepts data
containing a key-value pair object and a valid Joi Type Schema joiSchema
, and validates it using Joi.validate()
.
Return values:
error
-true
if there is an error, otherwisefalse
.errors
- contains an array ofkey
andvalue
. Holds the error messages.key
- contains a thekey
/field
that have the error.value
- contains the error message.
var MarkJoiSchema = ; //validatelet ret = MarkJoiSchema;ifreterror return message: reterrors ; //returns error messages