first commit
This commit is contained in:
38
uni_modules/tdesign-uniapp/components/common/validator.js
Normal file
38
uni_modules/tdesign-uniapp/components/common/validator.js
Normal file
@@ -0,0 +1,38 @@
|
||||
export function isFunction(val) {
|
||||
return typeof val === 'function';
|
||||
}
|
||||
|
||||
export const isString = val => typeof val === 'string';
|
||||
|
||||
export const isNull = value => value === null;
|
||||
|
||||
export const isUndefined = value => value === undefined;
|
||||
|
||||
export function isDef(value) {
|
||||
return !isUndefined(value) && !isNull(value);
|
||||
}
|
||||
|
||||
export function isInteger(value) {
|
||||
return Number.isInteger(value);
|
||||
}
|
||||
|
||||
export function isNumeric(value) {
|
||||
return !Number.isNaN(Number(value));
|
||||
}
|
||||
|
||||
export function isNumber(value) {
|
||||
return typeof value === 'number';
|
||||
}
|
||||
|
||||
export function isBoolean(value) {
|
||||
return typeof value === 'boolean';
|
||||
}
|
||||
|
||||
export function isObject(x) {
|
||||
const type = typeof x;
|
||||
return x !== null && (type === 'object' || type === 'function');
|
||||
}
|
||||
|
||||
export function isPlainObject(val) {
|
||||
return val !== null && typeof val === 'object' && Object.prototype.toString.call(val) === '[object Object]';
|
||||
}
|
||||
Reference in New Issue
Block a user