mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
Properly validates Integer Survey Question with min value of 0
This commit is contained in:
parent
7eefa897b3
commit
adaa24a562
@ -72,7 +72,7 @@ function getInitialValues(launchConfig, surveyConfig, resource) {
|
||||
? question.default.split('\n')
|
||||
: [];
|
||||
} else {
|
||||
values[`survey_${question.variable}`] = question.default || '';
|
||||
values[`survey_${question.variable}`] = question.default ?? '';
|
||||
}
|
||||
if (resource?.extra_data) {
|
||||
Object.entries(resource.extra_data).forEach(([key, value]) => {
|
||||
@ -129,11 +129,14 @@ function checkForError(launchConfig, surveyConfig, values) {
|
||||
}
|
||||
}
|
||||
if (isNumeric && (value || value === 0)) {
|
||||
if (value < question.min || value > question.max) {
|
||||
if (
|
||||
(value < question.min || value > question.max) &&
|
||||
question.required
|
||||
) {
|
||||
hasError = true;
|
||||
}
|
||||
}
|
||||
if (question.required && (!value || value.length === 0)) {
|
||||
if (question.required && (!value || value.length === 0) && !isNumeric) {
|
||||
hasError = true;
|
||||
}
|
||||
});
|
||||
|
||||
@ -114,7 +114,7 @@ function SurveyQuestionForm({
|
||||
variable: question?.variable || '',
|
||||
min: question?.min || 0,
|
||||
max: question?.max || 1024,
|
||||
default: question?.default || '',
|
||||
default: question?.default ?? '',
|
||||
choices: question?.choices || '',
|
||||
formattedChoices: [{ choice: '', isDefault: false, id: 0 }],
|
||||
new_question: !question,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user