Looking to set up JOI validation in Node.js that flags errors if a string begins or ends with an empty space. For example: name = "test123" //valid name = "test(space)" or "(space)test" // invalid ...
Is there a way to achieve this using Joi? For instance: Joi.string() .required() .min(8) .max(16) .pattern(/(?=(?:.*[a-z]){2,16}).+/) .pattern(/(?=(?:.*[A-Z]){2,16}).+/) .pattern(/(?=(?:.*[0-9]){2,16}).+/) .pa ...
Currently, I am facing an issue with the Joi object in my code. I am attempting to use the Or method but it seems to be failing due to having two objects that contain the phone property. body: Joi.object().keys({ member: Joi.object().required( ...
Within my server-side JavaScript code, I am utilizing Joi for validating a JavaScript object. The schema being used is structured as follows: var schema = Joi.object().keys({ displayName: Joi.string().required(), email: Joi.string().email(), e ...
I'm attempting to personalize a message for the .or() function in Joi, similar to this: https://i.stack.imgur.com/68dKx.png The default message from Joi is as follows: Validation Error: "value" must contain at least one of [optionOne, optionTwo] I wou ...
I have two different interfaces, where the second one is an extension of the first: interface Core { id: string; } interface User extends Core { firstName: string; } To ensure validation, I utilize Joi schemas. For the Core interface, it's easy to p ...
One of the challenges I'm facing with my API is handling POST-sent payload input that needs to be passed on to another application for processing. The input is always in JSON format, and the values must strictly be numeric. With hundreds of different varia ...
I am encountering some challenges while trying to use an NPM module that I developed along with its Typescript typings in another application. To simplify the examples, I will omit properties that are not relevant to the issue at hand. Within my module&ap ...
I have implemented a joi schema to validate email and password that are sent as JSON in the request body. Now, I want to add an additional validation for the IP address. However, when I tried to do so, I encountered the following error: { "isJoi": tru ...
In my quest to create a multi-step form with React.js and material UI, I encountered an issue with Joi-Browser validation. The error message states: ValidationError: "value" must be an object. Since I am new to React.js, I would appreciate any guidance on ...
I am currently developing a NestJs backend on multiple machines. One of the machines is experiencing issues with the @hapi/joi package. When running the NestJs application in development mode on this specific machine, I encounter the following error: PS C ...
Currently, I am facing an issue with nodejs+mongodb. When uploading images on the front-end, the system restricts it to a maximum size of 50kb. However, I would like to increase this limit to 5MB so that larger images (around 1MB or 2MB) can also be upload ...
I need to validate a field within an object based on specific values in another field. Let's say I have two fields, field1 and field2. The possible values for field1 are A, B, C, D, E, F, H, I. If field1 has the value of A, B, or C, then field2 should be n ...
I'm currently working with a Joi model that looks like this: const SimpleModel = Joi.object({ id: Joi.number().integer().required().description('ID') }).label('SimpleModel'); This model is being utilized in the following route within @hapi/hapi: { ...
I am currently working on a registration form that requires validation using Joi. While I have been able to successfully reflect errors in JSON format, I am facing difficulty in displaying these errors on the frontend. Previously, with express-validator, I ...
I need to implement a dynamic validation system that involves downloading an object at runtime and saving it as a well-formed .json file. The objective is to use the values from this downloaded object as part of a validation process using Joi.validate wi ...
Currently, I am in the process of creating a route that handles file uploads (POST) and also stores additional properties to MongoDB along with the file path. The issue I am facing is that even if input validation fails, the file still gets uploaded to the ...
I have been encountering an issue while trying to validate my payload using a joi schema. Instead of returning the errors specified in the schema, only one error is being displayed. Even when I provide a payload with name as "int", it only shows one custom ...
I am having trouble extending the joi class with custom operators. My goal is to validate MongoDB Ids, but when I try to use the extended object, I encounter the following error: error: uncaughtException: JoiObj.string(...).objectId is not a function TypeE ...
How can we apply Joi validation to the schema shown below? What is the process for validating nested objects and arrays in this context? const user = { address: { contactName: 'Sunny', detailAddress: { line1: 'Sector: ...
Currently, I am in the process of creating Apis utilizing NodeJS and ExpressJS with Joi for schema validation. In one instance, I have a resetUserPinCode controller where I need to ensure that the oldPinCode and newPinCode values are not identical: const r ...
Currently experimenting with Joi for object validation. Able to validate objects with constraints on two keys using any.when(). Now looking to implement validation with constraints on three keys, for example: var object = { dynamicPrize: false, ...
Just entering the world of mongoose and looking to validate an array with specific predefined values like enum. Check out my schema below: const movieSchema = new mongoose.Schema({ language:{ type:[String], enum : ['Hindi','English','Gujarati',' ...
I am looking to strengthen password security during user registration by utilizing the joi-password-complexity package. https://github.com/kamronbatman/joi-password-complexity However, I encountered an error when attempting to implement it: (node:1487 ...
const validationSchema = Joi.object().keys({ Id: Joi.number().required(), CustomerName: Joi.string() .trim() .required() .when('$isInValidCustomer', { is: true, ...
I am working with a schema that looks like this: How can I determine if all the fields in the schema have been filled or not? The front-end (React.js) includes an onboarding process where users who are logging in for the first time need to complete onboa ...