Skip to content
Snippets Groups Projects
Commit 84391ccd authored by Timothee P's avatar Timothee P :sunflower:
Browse files

check for irregular characters

parent e9890953
No related branches found
No related tags found
1 merge request!65REDMINE_ISSUES-11772
This commit is part of merge request !65. Comments created here will be created in the context of that merge request.
...@@ -249,12 +249,14 @@ export default { ...@@ -249,12 +249,14 @@ export default {
} }
this.updateStore(); this.updateStore();
}, },
removeCustomForm() { removeCustomForm() {
this.$store.commit( this.$store.commit(
"feature_type/REMOVE_CUSTOM_FORM", "feature_type/REMOVE_CUSTOM_FORM",
this.customForm.dataKey this.customForm.dataKey
); );
}, },
updateStore() { updateStore() {
const data = { const data = {
dataKey: this.customForm.dataKey, dataKey: this.customForm.dataKey,
...@@ -266,10 +268,21 @@ export default { ...@@ -266,10 +268,21 @@ export default {
}; };
this.$store.commit("feature_type/UPDATE_CUSTOM_FORM", data); this.$store.commit("feature_type/UPDATE_CUSTOM_FORM", data);
}, },
trimWhiteSpace(string) { trimWhiteSpace(string) {
// TODO : supprimer les espaces pour chaque option au début et à la fin QUE à la validation // TODO : supprimer les espaces pour chaque option au début et à la fin QUE à la validation
return string.replace(/\s*,\s*/gi, ","); return string.replace(/\s*,\s*/gi, ",");
}, },
hasRegularCharacters(input) {
for (let char of input) {
if (!/[a-zA-Z0-9-_]/.test(char)) {
return false;
}
}
return true;
},
checkCustomForm() { checkCustomForm() {
if (this.form.label.value === null) { if (this.form.label.value === null) {
this.form.label.errors = ["Veuillez compléter ce champ."]; this.form.label.errors = ["Veuillez compléter ce champ."];
...@@ -278,6 +291,12 @@ export default { ...@@ -278,6 +291,12 @@ export default {
this.form.name.errors = ["Veuillez compléter ce champ."]; this.form.name.errors = ["Veuillez compléter ce champ."];
this.form.label.errors = []; this.form.label.errors = [];
return false; return false;
} else if (!this.hasRegularCharacters(this.form.name.value)) {
this.form.name.errors = [
"Veuillez utiliser seulement les caratères autorisés.",
];
this.form.label.errors = [];
return false;
} }
this.form.label.errors = []; this.form.label.errors = [];
this.form.name.errors = []; this.form.name.errors = [];
......
...@@ -154,7 +154,6 @@ ...@@ -154,7 +154,6 @@
Créer et importer le(s) signalement(s) du geojson Créer et importer le(s) signalement(s) du geojson
</button> </button>
<!-- // TODO: Add check script for form & other scripts // -->
</form> </form>
</div> </div>
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment