commit
This commit is contained in:
27
src/utils/flunt.ts
Normal file
27
src/utils/flunt.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
export class Flunt {
|
||||
constructor(public errors: any[] = [])
|
||||
{}
|
||||
|
||||
isRequired(value, message){
|
||||
if (!value || value.length <= 0) {
|
||||
this.errors.push(message);
|
||||
}
|
||||
}
|
||||
|
||||
hasMinLen( value, min, message) {
|
||||
if (!value || value.length <= min) {
|
||||
this.errors.push(message);
|
||||
}
|
||||
}
|
||||
|
||||
hasMaxLen( value, max, message) {
|
||||
if (!value || value.length >= max) {
|
||||
this.errors.push(message);
|
||||
}
|
||||
}
|
||||
|
||||
isValid(): boolean {
|
||||
return this.errors.length == 0;
|
||||
}
|
||||
|
||||
}
|
||||
6
src/utils/number.utils.ts
Normal file
6
src/utils/number.utils.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
export class NumberUtils {
|
||||
|
||||
static getNewId(max: number, min: number) {
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user