hapijs

Validating nested objects with Joi

北战南征 提交于 2020-08-07 05:30:38
问题 How to validate this object using joi? Im using Joi with Hapi api. { "email":"rambo@gmail.com", "password":"abc123", "active":"", "details": { "firstName": "Rambo", "lastName": "Comando", "phoneNumber": "5554446655", "billing":{ "firstName": "", "lastName": "", "phoneNumber": "", "address": "", "adress2": "", "postalCode": "", "city": "", "state": "", "country": "", "stripeId": "" } } } I tried doing like this, but it is not working. What is the correct way of doing this? payload: { email:

Validating nested objects with Joi

爱⌒轻易说出口 提交于 2020-08-07 05:30:11
问题 How to validate this object using joi? Im using Joi with Hapi api. { "email":"rambo@gmail.com", "password":"abc123", "active":"", "details": { "firstName": "Rambo", "lastName": "Comando", "phoneNumber": "5554446655", "billing":{ "firstName": "", "lastName": "", "phoneNumber": "", "address": "", "adress2": "", "postalCode": "", "city": "", "state": "", "country": "", "stripeId": "" } } } I tried doing like this, but it is not working. What is the correct way of doing this? payload: { email:

Validating nested objects with Joi

馋奶兔 提交于 2020-08-07 05:29:58
问题 How to validate this object using joi? Im using Joi with Hapi api. { "email":"rambo@gmail.com", "password":"abc123", "active":"", "details": { "firstName": "Rambo", "lastName": "Comando", "phoneNumber": "5554446655", "billing":{ "firstName": "", "lastName": "", "phoneNumber": "", "address": "", "adress2": "", "postalCode": "", "city": "", "state": "", "country": "", "stripeId": "" } } } I tried doing like this, but it is not working. What is the correct way of doing this? payload: { email:

Validating nested objects with Joi

|▌冷眼眸甩不掉的悲伤 提交于 2020-08-07 05:29:07
问题 How to validate this object using joi? Im using Joi with Hapi api. { "email":"rambo@gmail.com", "password":"abc123", "active":"", "details": { "firstName": "Rambo", "lastName": "Comando", "phoneNumber": "5554446655", "billing":{ "firstName": "", "lastName": "", "phoneNumber": "", "address": "", "adress2": "", "postalCode": "", "city": "", "state": "", "country": "", "stripeId": "" } } } I tried doing like this, but it is not working. What is the correct way of doing this? payload: { email:

Joi Regex is not recognized as Regex Pattern

纵然是瞬间 提交于 2020-06-28 02:09:44
问题 I'm trying to make a validation rule for password field that it should consists of the following: Must have a number Must contain at least one upper-case Must contain at least one lower-case Must contain any of the following symbols [@$!] Should be at 8 to 20 characters only. Here's the regex pattern I use: (?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[$@$!#.])[A-Za-z\d$@$!%*?&.]{8,20} Tested on https://regexr.com/ Here's the Joi validation: password: Joi.string() .regex( '/(?=.*[a-z])(?=.*[A-Z])(?=.*d

Multiple Joi validation types

泄露秘密 提交于 2020-06-25 09:33:07
问题 I search a lot but nothing found to allow multiple type validation in Joi Link: https://github.com/hapijs/joi I would like to use something like this: validate: { type: joi.or([ joi.string(), joi.array(), ]) }; 回答1: Try: validate: { type: joi.alternatives().try(joi.string(), joi.array()) } or: validate: { type: [joi.string(), joi.array()] } See: https://github.com/hapijs/joi/blob/v10.1.0/API.md#alternatives 回答2: export const saveDeviceCommandsSchema = { devices: [ Joi.array().items(Joi.string