-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
supportQuestions, discussions, and general supportQuestions, discussions, and general support
Description
Support plan
- which support plan is this issue covered by? (e.g. Community, Core, Plus, or Enterprise):
- is this issue currently blocking your project? (yes/no):
- is this issue affecting a production system? (yes/no):
Context
- node version: v13.6.0
- module version: 17.1.1
- environment (e.g. node, browser, native): node
- used with (e.g. hapi application, another framework, standalone, ...): standalone
- any other relevant information: N/A
How can we help?
I was searching to make actual validation logic along with data format or type check.
for example: define and check if a record with id (given in the input params) exists.
I've tried external but the problem is value is not replaced so I have to fetch the object again after the validation
async function method(id) {
const user = await User.findById(id)
if !_.isNil(user) {
return new Error("user is not found");
} else {
return user
}
}
const schema = Joi.object({
name: Joi.string().required(),
id: Joi.number().external(method, "custom validation")
})so I am asking if that's supported
an example from ruby code
params do
required(:room_id).value(:integer)
required(:user_id).value(:integer)
required(:start_date).value(:time)
required(:end_date).value(:time)
optional(:notes).value(:string)
end
rule(:room_id) do
room = Room.find_by(id: value)
if room.present?
values[:room] = room
else
key.failure('could not be found')
end
endReactions are currently unavailable
Metadata
Metadata
Assignees
Labels
supportQuestions, discussions, and general supportQuestions, discussions, and general support