fix: give fields a user-friendly label
This commit is contained in:
parent
fc47944ac8
commit
f1566c1bcc
4 changed files with 31 additions and 11 deletions
|
|
@ -65,7 +65,9 @@ const ChooseType = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
inputType: Yup.string().required()
|
inputType: Yup.string()
|
||||||
|
.label('Input type')
|
||||||
|
.required()
|
||||||
})
|
})
|
||||||
|
|
||||||
const defaultValues = {
|
const defaultValues = {
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,12 @@ const Screen1Information = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
screen1Title: Yup.string().required(),
|
screen1Title: Yup.string()
|
||||||
screen1Text: Yup.string().required()
|
.label('Screen title')
|
||||||
|
.required(),
|
||||||
|
screen1Text: Yup.string()
|
||||||
|
.label('Screen text')
|
||||||
|
.required()
|
||||||
})
|
})
|
||||||
|
|
||||||
const defaultValues = {
|
const defaultValues = {
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,12 @@ const ScreenInformation = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
screen2Title: Yup.string().required(),
|
screen2Title: Yup.string()
|
||||||
screen2Text: Yup.string().required()
|
.label('Screen title')
|
||||||
|
.required(),
|
||||||
|
screen2Text: Yup.string()
|
||||||
|
.label('Screen text')
|
||||||
|
.required()
|
||||||
})
|
})
|
||||||
|
|
||||||
const defaultValues = {
|
const defaultValues = {
|
||||||
|
|
|
||||||
|
|
@ -40,28 +40,38 @@ const validationSchema = Yup.lazy(values => {
|
||||||
switch (values.inputType) {
|
switch (values.inputType) {
|
||||||
case 'numerical':
|
case 'numerical':
|
||||||
return Yup.object({
|
return Yup.object({
|
||||||
constraintType: Yup.string().required(),
|
constraintType: Yup.string()
|
||||||
|
.label('Constraint type')
|
||||||
|
.required(),
|
||||||
inputLength: Yup.number().when('constraintType', {
|
inputLength: Yup.number().when('constraintType', {
|
||||||
is: 'length',
|
is: 'length',
|
||||||
then: Yup.number()
|
then: Yup.number()
|
||||||
.min(0)
|
.min(0)
|
||||||
.required(),
|
.required('The number of digits is required'),
|
||||||
else: Yup.mixed().notRequired()
|
else: Yup.mixed().notRequired()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
case 'text':
|
case 'text':
|
||||||
return Yup.object({
|
return Yup.object({
|
||||||
constraintType: Yup.string().required(),
|
constraintType: Yup.string()
|
||||||
inputLabel1: Yup.string().required(),
|
.label('Constraint type')
|
||||||
|
.required(),
|
||||||
|
inputLabel1: Yup.string()
|
||||||
|
.label('Text entry label')
|
||||||
|
.required(),
|
||||||
inputLabel2: Yup.string().when('constraintType', {
|
inputLabel2: Yup.string().when('constraintType', {
|
||||||
is: 'spaceSeparation',
|
is: 'spaceSeparation',
|
||||||
then: Yup.string().required(),
|
then: Yup.string()
|
||||||
|
.label('Second word label')
|
||||||
|
.required(),
|
||||||
else: Yup.mixed().notRequired()
|
else: Yup.mixed().notRequired()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
case 'choiceList':
|
case 'choiceList':
|
||||||
return Yup.object({
|
return Yup.object({
|
||||||
constraintType: Yup.string().required(),
|
constraintType: Yup.string()
|
||||||
|
.label('Constraint type')
|
||||||
|
.required(),
|
||||||
listChoices: Yup.array().test(
|
listChoices: Yup.array().test(
|
||||||
'has-2-or-more',
|
'has-2-or-more',
|
||||||
'Choice list needs to have two or more non empty fields',
|
'Choice list needs to have two or more non empty fields',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue