rename dv to dataValidation for readability
This commit is contained in:
parent
e1c4b0c237
commit
96101b11b1
|
@ -1,4 +1,4 @@
|
||||||
import dv from "./dv.mjs"
|
import dv from "./dataValidation.mjs"
|
||||||
export default class Entity{
|
export default class Entity{
|
||||||
set _id(prop){
|
set _id(prop){
|
||||||
if(prop){
|
if(prop){
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import Title from "./Title.mjs";
|
import Title from "./Title.mjs";
|
||||||
import dv from "./dv.mjs";
|
import dataValidation from "./dataValidation.mjs";
|
||||||
export default class Publication extends Title{
|
export default class Publication extends Title{
|
||||||
set _link(prop){
|
set _link(prop){
|
||||||
if(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
|
this.link=prop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import Entity from "./Entity.mjs";
|
import Entity from "./Entity.mjs";
|
||||||
import dv from "./dv.mjs";
|
import dataValidation from "./dataValidation.mjs";
|
||||||
//THIS CLASS WILL HANDLE JUNCTION TABLE STUFF
|
//THIS CLASS WILL HANDLE JUNCTION TABLE STUFF
|
||||||
export default class Title extends Entity{
|
export default class Title extends Entity{
|
||||||
set _title(prop){
|
set _title(prop){
|
||||||
if(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
|
this.title=prop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set _genres(prop){
|
set _genres(prop){
|
||||||
if(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
|
this.genres=prop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue