-
-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
💬 Questions and Help
I don't find if it is possible to write this json schema:
{
"type": "object",
"properties": {
"type": {
"type": "string",
"enum": ["AS", "RP"]
}
},
"if": {
"properties": { "type": { "const": "RP" } }
},
"then": {
"properties": { "issueType": { "type": "string" } },
"required": [ "issueType" ]
}
}
I'm trying the code:
const S = require('fluent-schema')
const fs = S.object()
.prop('type', S.string().enum(['AS', 'CS', 'RP']))
.ifThen(
// S.object().prop('type', S.string().default('RP')),
S.object().prop('type', 'RP'),
S.object().prop('issueType', S.string().required())
)
console.log(JSON.stringify(fs.valueOf(), null, 2))
But I get:
"if": {
"properties": {
"type": {
"0": "R",
"1": "P"
}
}
},
or
"if": {
"properties": {
"type": {
"type": "string",
"default": "RP"
}
}
},
Should I use S.raw?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working