types update
This commit is contained in:
parent
dc5f6fe531
commit
5b620980e3
1 changed files with 4 additions and 4 deletions
|
|
@ -85,19 +85,19 @@ export const NotificationValidate = (o?: Notification, opts: NotificationOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ServiceNpub = {
|
export type ServiceNpub = {
|
||||||
npub: string
|
pubkey_hex: string
|
||||||
}
|
}
|
||||||
export const ServiceNpubOptionalFields: [] = []
|
export const ServiceNpubOptionalFields: [] = []
|
||||||
export type ServiceNpubOptions = OptionsBaseMessage & {
|
export type ServiceNpubOptions = OptionsBaseMessage & {
|
||||||
checkOptionalsAreSet?: []
|
checkOptionalsAreSet?: []
|
||||||
npub_CustomCheck?: (v: string) => boolean
|
pubkey_hex_CustomCheck?: (v: string) => boolean
|
||||||
}
|
}
|
||||||
export const ServiceNpubValidate = (o?: ServiceNpub, opts: ServiceNpubOptions = {}, path: string = 'ServiceNpub::root.'): Error | null => {
|
export const ServiceNpubValidate = (o?: ServiceNpub, opts: ServiceNpubOptions = {}, path: string = 'ServiceNpub::root.'): Error | null => {
|
||||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||||
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
if (typeof o !== 'object' || o === null) return new Error(path + ': object is not an instance of an object or is null')
|
||||||
|
|
||||||
if (typeof o.npub !== 'string') return new Error(`${path}.npub: is not a string`)
|
if (typeof o.pubkey_hex !== 'string') return new Error(`${path}.pubkey_hex: is not a string`)
|
||||||
if (opts.npub_CustomCheck && !opts.npub_CustomCheck(o.npub)) return new Error(`${path}.npub: custom check failed`)
|
if (opts.pubkey_hex_CustomCheck && !opts.pubkey_hex_CustomCheck(o.pubkey_hex)) return new Error(`${path}.pubkey_hex: custom check failed`)
|
||||||
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue