strapi/packages/strapi-admin/validation/common-functions/check-fields-dont-have-duplicates.js
Pierre Noël b6a5e78fe3 fix bad nesting
Signed-off-by: Pierre Noël <petersg83@gmail.com>
2020-07-08 11:47:19 +02:00

17 lines
339 B
JavaScript

'use strict';
const _ = require('lodash');
const checkFieldsDontHaveDuplicates = fields => {
if (_.isNil(fields)) {
// Only check if the fields exist
return true;
} else if (!Array.isArray(fields)) {
return false;
}
return _.uniq(fields).length === fields.length;
};
module.exports = checkFieldsDontHaveDuplicates;