Questions tagged [joi]

Object schema description language and validator for JavaScript objects.

Further:

1003 questions
0
votes
2 answers

hapijs with jade view engine best way to display errors

I would like to display my error message in my jade view after validation. Jade H1 Hello world #error p #{JSON.stringify(errorMsg)} div form(action="/",method="post") div Foo div input(type="text",name="foo") div …
silverfighter
  • 6,762
  • 10
  • 46
  • 73
0
votes
1 answer

Validation on multivalue HTTP header with Node and hapijs/joi

I'm trying to validate an Accept header in my REST api written in Node.js on Hapijs framework. When I request my resource from Firefox which creates a request with following accept header: Accept:…
Jackie
  • 5
  • 6
0
votes
2 answers

How to properly share Hapi Joi validation schemas between models without circular dependency

I am creating an API using HAPI and Joi to validate inputs and I am having troubles with sharing my validation schema between different modules. I am using a component-oriented architecture that looks like that components |_ moduleA |_…
ChrisV
  • 233
  • 4
  • 15
0
votes
1 answer

How to use Arrays in Hapi swaggered-ui on GET request so it would work?

Usecase: Hapi.js + hapi-swaggered + hapi-swaggered-ui. Swaggered UI submits an array. It passes comma separated String instead of Array. How to I make it pass correct parameters, should I change validation type on Joi? I am using: query:…
0
votes
1 answer

hapi joi filter valid value

Is there a way to do the same var item = new Item(request.payload); item.tags = _.map(item.tags, function(s){ return s.trim().toLowerCase(); }); in the validation code ? var Joi = require('joi'), Tags =…
Whisher
  • 31,320
  • 32
  • 120
  • 201
0
votes
1 answer

Hapi Joi multiple alternative matches

I would like field 'a' to be required when 'b' is either 'foo' or 'bar' but otherwise optional. I see docs for a single field: a: Joi.string().when('b', { is: 'foo', then: Joi.required() }) How would I achieve the above?
cyberwombat
  • 38,105
  • 35
  • 175
  • 251
-1
votes
1 answer

How do I use joi to validate email

I have been stuck on how I can validate using joi npm. Please how do I get to render the register and login route for the user to access without using the ejs or html? And also create a protected route const express = require("express"); const Joi =…
bryan
  • 9
  • 3
-1
votes
2 answers

JS using dot, string notation to map nested and assign errors

Ok, this is an odd one that I just can't seem to get right. I have a large, complex object to send to a backend. After various attempts, I tried using Joi to validate the schema, and I like it, but passing the errors back to the inputs is a…
JJ McGregor
  • 182
  • 1
  • 12
-1
votes
1 answer

I am getting this `TypeError: Cannot read property 'string' of undefined` while i am creating a new user

I am getting an error that Cannot read property 'string' of undefined however i downloaded the joi module npm i @hapo/joi. i don't understand what is the error is about. it refers to this part of code in the validation file username:…
Hesham Eldawy
  • 75
  • 1
  • 11
-1
votes
2 answers

joi validation each items of array object must have same value

i have form request like this { "data": [ { "transaction": "LNS", "product": "XXX", "lot": "1", "liquidPrice": "0", "liquidId": 0, "limitPrice": "1780.00", …
-1
votes
1 answer

AssertionError [ERR_ASSERTION]: you must pass Joi as an argument

How do I solve this Joi problem(Using express, joi@17.4.2,joi-objectid@2.0.0, ,mongoose) I am trying to link two mongoose schemas using ref as { ... enroledcourses: [{ type: Schema.Types.ObjectId, ref: "courses" }] } joi…
-1
votes
1 answer

Express - Validation for Patch Requests

I'm a front-end dev trying to create the rest api for my project with Node/Express. I'm using Joi for validtion. I'm curios how can I PATCH request routes. I cannot use Joi because it says this field is required. so I'm wondering how can I validate…
Xaarth
  • 1,021
  • 3
  • 12
  • 34
-1
votes
1 answer

Form validation with Joi fails when sending files

I have endpoint where I post some data to create a user. I am validating the request body with Joi. But when I post using Postman, validation fails. Here, something similar to the validation function, const checkData = (data) => { const schema =…
Hasan
  • 247
  • 7
  • 22
-1
votes
1 answer

multiple regex/pattern validation Joi Hapi

Hi guys i want to make a mutiple regex validation with joi/hapi but i don't understand how to do it i already multiple try but no one works, I want the password minimun have 1 capital letter, 1 minus letter, 1 number and 1 special character here…
Ganzo
  • 198
  • 1
  • 3
  • 16
-1
votes
1 answer

send custom json response with joi path param validator in typescipt

I have route with GET method which accepts a id param in url path. I am validating that id with a regex patteren. I can successfully validate with below code. const validate = require("express-joi-validate"); router.get("/finderrorlog/:id",…
TechChain
  • 8,404
  • 29
  • 103
  • 228
1 2 3
66
67