@credo-ts/core
Version:
<p align="center"> <br /> <img alt="Credo Logo" src="https://github.com/openwallet-foundation/credo-ts/blob/c7886cb8377ceb8ee4efe8d264211e561a75072d/images/credo-logo.png" height="250px" /> </p> <h1 align="center"><b>Credo - Core</b></h1
1 lines • 2.15 kB
Source Map (JSON)
{"version":3,"file":"DidDocumentService.mjs","names":[],"sources":["../../../../../src/modules/dids/domain/service/DidDocumentService.ts"],"sourcesContent":["import type { ValidationOptions } from 'class-validator'\n\nimport { buildMessage, IsString, isString, ValidateBy } from 'class-validator'\n\nimport { isJsonObject, type SingleOrArray } from '../../../../types'\n\ntype ServiceEndpointType = SingleOrArray<string | Record<string, unknown>>\n\nexport class DidDocumentService {\n public constructor(options: { id: string; serviceEndpoint: ServiceEndpointType; type: string }) {\n if (options) {\n this.id = options.id\n this.serviceEndpoint = options.serviceEndpoint\n this.type = options.type\n }\n }\n\n @IsString()\n public id!: string\n\n @IsStringOrJsonObjectSingleOrArray()\n public serviceEndpoint!: SingleOrArray<string | Record<string, unknown>>\n\n @IsString()\n public type!: string\n}\n\n/**\n * Checks if a given value is a string, a json object, or an array of strings and json objects\n */\nfunction IsStringOrJsonObjectSingleOrArray(validationOptions?: Omit<ValidationOptions, 'each'>): PropertyDecorator {\n return ValidateBy(\n {\n name: 'isStringOrJsonObjectSingleOrArray',\n validator: {\n validate: (value): boolean =>\n isString(value) ||\n isJsonObject(value) ||\n (Array.isArray(value) && value.every((v) => isString(v) || isJsonObject(v))),\n defaultMessage: buildMessage(\n (eachPrefix) =>\n `${eachPrefix}$property must be a string, JSON object, or an array consisting of strings and JSON objects`,\n validationOptions\n ),\n },\n },\n validationOptions\n )\n}\n"],"mappings":";;;;;;;;AAQA,IAAa,qBAAb,MAAgC;CAC9B,AAAO,YAAY,SAA6E;AAC9F,MAAI,SAAS;AACX,QAAK,KAAK,QAAQ;AAClB,QAAK,kBAAkB,QAAQ;AAC/B,QAAK,OAAO,QAAQ;;;;YAIvB,UAAU;YAGV,mCAAmC;YAGnC,UAAU;;;;AAOb,SAAS,kCAAkC,mBAAwE;AACjH,QAAO,WACL;EACE,MAAM;EACN,WAAW;GACT,WAAW,UACT,SAAS,MAAM,IACf,aAAa,MAAM,IAClB,MAAM,QAAQ,MAAM,IAAI,MAAM,OAAO,MAAM,SAAS,EAAE,IAAI,aAAa,EAAE,CAAC;GAC7E,gBAAgB,cACb,eACC,GAAG,WAAW,8FAChB,kBACD;GACF;EACF,EACD,kBACD"}