Front: Api models validation (#245)
* Front: Model: Write Validators * Front: Plage response validator * Front: API: Typing 'fetch' return * Front: Basic Models: Response Handlers * Front: API: Validate authentication response * Front: Validate Search History * Front: Validate Responses of User updates * Front: On Validation Error, more verbose console error
This commit is contained in:
+13
-20
@@ -1,26 +1,19 @@
|
||||
import Skill from './Skill';
|
||||
import Model from './Model';
|
||||
import { SkillValidator } from './Skill';
|
||||
import { ModelValidator } from './Model';
|
||||
import * as yup from 'yup';
|
||||
|
||||
export const LessonValidator = yup
|
||||
.object({
|
||||
name: yup.string().required(),
|
||||
description: yup.string().required(),
|
||||
requiredLevel: yup.number().required(),
|
||||
mainSkill: SkillValidator.required(),
|
||||
})
|
||||
.concat(ModelValidator);
|
||||
|
||||
/**
|
||||
* A Lesson is an exercice that the user can try to practice a skill
|
||||
*/
|
||||
interface Lesson extends Model {
|
||||
/**
|
||||
* The title of the lesson
|
||||
*/
|
||||
title: string;
|
||||
/**
|
||||
* Short description of the lesson
|
||||
*/
|
||||
description: string;
|
||||
/**
|
||||
* The minimum level required for the user to access this lesson
|
||||
*/
|
||||
requiredLevel: number;
|
||||
/**
|
||||
* The main skill learnt in this lesson
|
||||
*/
|
||||
mainSkill: Skill;
|
||||
}
|
||||
type Lesson = yup.InferType<typeof LessonValidator>;
|
||||
|
||||
export default Lesson;
|
||||
|
||||
Reference in New Issue
Block a user