mirror of
https://github.com/iptv-org/database.git
synced 2025-05-09 19:20:01 -04:00
33 lines
560 B
TypeScript
33 lines
560 B
TypeScript
import { CategoryData } from '../types/category'
|
|
import { Model } from './model'
|
|
import Joi from 'joi'
|
|
|
|
export class Category extends Model {
|
|
id: string
|
|
name: string
|
|
|
|
constructor(data: CategoryData) {
|
|
super()
|
|
|
|
this.id = data.id
|
|
this.name = data.name
|
|
}
|
|
|
|
data(): CategoryData {
|
|
return {
|
|
id: this.id,
|
|
name: this.name
|
|
}
|
|
}
|
|
|
|
getSchema() {
|
|
return Joi.object({
|
|
id: Joi.string()
|
|
.regex(/^[a-z]+$/)
|
|
.required(),
|
|
name: Joi.string()
|
|
.regex(/^[A-Z]+$/i)
|
|
.required()
|
|
})
|
|
}
|
|
}
|