Merge pull request #1148 from chaotixkilla/fix-custom-reqs-same-name-casing

Standardize custom reqs and machine names before comparing
This commit is contained in:
Rafael Taranto 2022-03-10 13:33:59 +00:00 committed by GitHub
commit e01e5f9b89
2 changed files with 7 additions and 3 deletions

View file

@ -125,7 +125,11 @@ const validationSchema = Yup.object().shape({
.test(
'unique-name',
'Machine name is already in use.',
(value, context) => !context.options.context.machineNames.includes(value)
(value, context) =>
!R.any(
it => R.equals(R.toLower(it), R.toLower(value)),
context.options.context.machineNames
)
)
})

View file

@ -34,8 +34,8 @@ const validationSchema = existingRequirements =>
'unique-name',
'A custom information requirement with that name already exists',
(value, _context) =>
!R.includes(
value,
!R.any(
it => R.equals(R.toLower(it), R.toLower(value)),
R.map(it => it.customRequest.name, existingRequirements)
)
)