-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codebugBug or defectBug or defect
Milestone
Description
Context
- node version: v6.10.2
- joi version: v10.4.2
- environment (node, browser): node
- used with (hapi, standalone, ...): standalone
- any other relevant information: macOS 10.12.14
What are you trying to achieve or the steps to reproduce ?
I thought it was fairly confusing that these options do not work together
const schema = Joi.string().valid(['A', 'B', 'C']).insensitive().lowercase()
schema.validate('A')
// { error: null, value: 'A' }
// or for uppercase
const anotherSchema = Joi.string().valid(['a', 'b', 'c']).insensitive().uppercase()
anotherSchema.validate('b')
// { error: null, value: 'b' }Which result you had ?
After validation with schema, the value was 'A'
After validation with anotherSchema, the value was 'b'
What did you expect ?
After validation with schema, the value should be 'a'
After validation with anotherSchema, the value should be 'B'
Now its fine that there is a workaround to just convert the array to the correct casing and use:
Joi.string().valid(['a', 'b', 'c']).lowercase();
schema.validate('A')
// { error: null, value: 'a' }but seems like odd behavior for this to not work with both. I can submit a PR if you agree.
Thanks for Joi!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
breaking changesChange that can breaking existing codeChange that can breaking existing codebugBug or defectBug or defect