podchat-browser
Version:
Javascript SDK to use POD's Chat Service - Browser Only
29 lines (25 loc) • 978 B
JavaScript
export default class Validation {
constructor(thread) {
this.thread = thread;
}
checkTypeCodeIsValid(params) {
if (!params?.typeCode) {
return true;
}
return params?.typeCode === this._app.typeCodes?.getActiveTypeCode()?.typeCode;
}
checkParameterIsValid(params) {
if (!params?.cache || params?.archived) {
return false;
}
if (!this.checkTypeCodeIsValid()) {
return false;
}
const invalidParams = ['query', 'name', 'username', 'cellphoneNumber', 'new', 'creatorCoreUserId', 'partnerCoreUserId', 'partnerCoreContactId', 'fromTime', 'toTime', 'isGroup', 'type'];
const hasForbiddenKeys = invalidParams.some(key => Object.keys(params).includes(key));
return !hasForbiddenKeys;
}
checkDataIsValid(params, threads) {
return threads?.length >= params.count && !threads?.includes(null)
}
}