Rectification d'un bug sur les liaisons et ajout de gestions d'erreurs sur la taille des strings

master
Raphael LACOTE 2 years ago
parent 91e54c0df4
commit d95677ab57

@ -5,7 +5,7 @@
<head>
<title>My awesome team</title>
<link rel="stylesheet" href="/css/style.css" />
<link rel="stylesheet" href="./css/style.css" />
</head>
<body>
@ -24,14 +24,15 @@
<script src="./src/misc/constant.js"></script>
<script src="./src/error/required_field_error.js"></script>
<script src="./src/error/string_size.js"></script>
<script type="module">
import { createApp } from 'https://unpkg.com/vue@3/dist/vue.esm-browser.js';
import Navbar from '/src/view/navbar.js';
import TeamAdd from '/src/view/team_add.js';
import Teamcard from '/src/view/teamcard.js';
import Navbar from './src/view/navbar.js';
import TeamAdd from './src/view/team_add.js';
import Teamcard from './src/view/teamcard.js';
const app = createApp({
data() {

@ -0,0 +1,5 @@
class StringSize extends Error {
constructor(field,sSize) {
super('Le champ ' + field + ' doit avoir une taille superieur à '+sSize);
}
}

@ -1 +1,3 @@
const ERROR_COLOR = 'red';
const DESCRIPTION_MINIMAL_SIZE = 20;
const NAME_MINIMAL_SIZE = 5;

@ -13,23 +13,25 @@ export default {
try {
this.errorMessage = '';
if (!this.id) {
this.name = '';
this.description= '';
throw new RequiredFieldError("ID");
return;
}
if (!this.name) {
this.id = '';
this.description= '';
throw new RequiredFieldError("Name");
return;
}
if (!this.description){
this.id = '';
this.name = '';
throw new RequiredFieldError("Description");
return;
}
if (this.description.length < DESCRIPTION_MINIMAL_SIZE) {
throw new StringSize("Description", DESCRIPTION_MINIMAL_SIZE)
}
if (this.name.length < NAME_MINIMAL_SIZE) {
throw new StringSize("Name", NAME_MINIMAL_SIZE)
}
console.log(this.description.length)
const team = { id: this.id, name: this.name, description: this.description};
console.log('form.addTeam', team);
@ -43,6 +45,9 @@ export default {
if (error instanceof RequiredFieldError) {
this.errorMessage=error
}
if (error instanceof StringSize) {
this.errorMessage = error
}
return null;
}
}

Loading…
Cancel
Save