1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00

feat(k8s): better form validation for configuration keys (#4728) (#4733)

Co-authored-by: Simon Meng <simon.meng@portainer.io>
This commit is contained in:
cong meng 2021-02-27 13:53:47 +13:00 committed by GitHub
parent ccf6babc02
commit f2faccdb10
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 2 deletions

View file

@ -1,6 +1,17 @@
import _ from 'lodash-es';
class KubernetesFormValidationHelper {
static getInvalidKeys(names) {
const res = {};
_.forEach(names, (name, index) => {
const valid = /^[-._a-zA-Z0-9]+$/.test(name);
if (!valid) {
res[index] = true;
}
});
return res;
}
static getDuplicates(names) {
const groupped = _.groupBy(names);
const res = {};