optional blind
This commit is contained in:
parent
86efd923d6
commit
a93aafc8ee
3 changed files with 8 additions and 7 deletions
|
|
@ -1394,7 +1394,7 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __invoice__: _string_
|
||||
|
||||
### OfferConfig
|
||||
- __blind__: _boolean_
|
||||
- __blind__: _boolean_ *this field is optional
|
||||
- __callback_url__: _string_
|
||||
- __createdAtUnix__: _number_
|
||||
- __default_offer__: _boolean_
|
||||
|
|
|
|||
|
|
@ -2824,7 +2824,7 @@ export const NewInvoiceResponseValidate = (o?: NewInvoiceResponse, opts: NewInvo
|
|||
}
|
||||
|
||||
export type OfferConfig = {
|
||||
blind: boolean
|
||||
blind?: boolean
|
||||
callback_url: string
|
||||
createdAtUnix: number
|
||||
default_offer: boolean
|
||||
|
|
@ -2837,10 +2837,11 @@ export type OfferConfig = {
|
|||
token: string
|
||||
updatedAtUnix: number
|
||||
}
|
||||
export const OfferConfigOptionalFields: [] = []
|
||||
export type OfferConfigOptionalField = 'blind'
|
||||
export const OfferConfigOptionalFields: OfferConfigOptionalField[] = ['blind']
|
||||
export type OfferConfigOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
blind_CustomCheck?: (v: boolean) => boolean
|
||||
checkOptionalsAreSet?: OfferConfigOptionalField[]
|
||||
blind_CustomCheck?: (v?: boolean) => boolean
|
||||
callback_url_CustomCheck?: (v: string) => boolean
|
||||
createdAtUnix_CustomCheck?: (v: number) => boolean
|
||||
default_offer_CustomCheck?: (v: boolean) => boolean
|
||||
|
|
@ -2857,7 +2858,7 @@ export const OfferConfigValidate = (o?: OfferConfig, opts: OfferConfigOptions =
|
|||
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.blind !== 'boolean') return new Error(`${path}.blind: is not a boolean`)
|
||||
if ((o.blind || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('blind')) && typeof o.blind !== 'boolean') return new Error(`${path}.blind: is not a boolean`)
|
||||
if (opts.blind_CustomCheck && !opts.blind_CustomCheck(o.blind)) return new Error(`${path}.blind: custom check failed`)
|
||||
|
||||
if (typeof o.callback_url !== 'string') return new Error(`${path}.callback_url: is not a string`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue