rename dv to dataValidation for readability

This commit is contained in:
Andrzej Stepien 2023-09-09 11:32:35 +02:00
parent e1c4b0c237
commit 96101b11b1
4 changed files with 29 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import dv from "./dv.mjs"
import dv from "./dataValidation.mjs"
export default class Entity{
set _id(prop){
if(prop){

View File

@ -1,9 +1,9 @@
import Title from "./Title.mjs";
import dv from "./dv.mjs";
import dataValidation from "./dataValidation.mjs";
export default class Publication extends Title{
set _link(prop){
if(prop){
if(!dv.isString(prop)){throw new TypeError("link must be a string")}
if(!dataValidation.isString(prop)){throw new TypeError("link must be a string")}
this.link=prop
}
}

View File

@ -1,16 +1,16 @@
import Entity from "./Entity.mjs";
import dv from "./dv.mjs";
import dataValidation from "./dataValidation.mjs";
//THIS CLASS WILL HANDLE JUNCTION TABLE STUFF
export default class Title extends Entity{
set _title(prop){
if(prop){
if(!dv.isString(prop)){throw new TypeError("title must be a string")}
if(!dataValidation.isString(prop)){throw new TypeError("title must be a string")}
this.title=prop
}
}
set _genres(prop){
if(prop){
if(!dv.isObject(prop)){throw new TypeError("genres must be an object")}
if(!dataValidation.isObject(prop)){throw new TypeError("genres must be an object")}
this.genres=prop
}
}

View File

@ -0,0 +1,23 @@
import { DateTime } from "luxon"
export default {
isNumber (n){
if(isNaN(n)){return false}
if (typeof n === "number") { return true }
return false
},
isString (s){
if (typeof s === 'string') { return true }
return false
},
dateStringIsValid(str){
if(str===null){return true}
if(DateTime.fromFormat(str,'yyyy-MM-dd').isValid){
return true
}
return false
},
isObject(objValue) {
return objValue && typeof objValue === 'object' && objValue.constructor === Object;
}
}