Introduce Service Id Types
Co-authored-by: Scott Nonnenberg <scott@signal.org>
This commit is contained in:
parent
414c0a58d3
commit
366b875fd2
269 changed files with 5832 additions and 5550 deletions
|
@ -3,7 +3,7 @@
|
|||
|
||||
import type { ValidateConversationType } from '../model-types.d';
|
||||
import { isDirectConversation } from './whatTypeOfConversation';
|
||||
import { isValidUuid } from '../types/UUID';
|
||||
import { isServiceIdString } from '../types/ServiceId';
|
||||
|
||||
export function validateConversation(
|
||||
attributes: ValidateConversationType
|
||||
|
@ -16,7 +16,7 @@ export function validateConversation(
|
|||
return 'Missing one of e164, uuid, or groupId';
|
||||
}
|
||||
|
||||
const error = validateNumber(attributes) || validateUuid(attributes);
|
||||
const error = validateNumber(attributes) || validateServiceId(attributes);
|
||||
|
||||
if (error) {
|
||||
return error;
|
||||
|
@ -38,13 +38,15 @@ function validateNumber(attributes: ValidateConversationType): string | null {
|
|||
return null;
|
||||
}
|
||||
|
||||
function validateUuid(attributes: ValidateConversationType): string | null {
|
||||
function validateServiceId(
|
||||
attributes: ValidateConversationType
|
||||
): string | null {
|
||||
if (isDirectConversation(attributes) && attributes.uuid) {
|
||||
if (isValidUuid(attributes.uuid)) {
|
||||
if (isServiceIdString(attributes.uuid)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return 'Invalid UUID';
|
||||
return 'Invalid ServiceId';
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue