File

src/issuer/configuration/credentials/dto/claim-field-definition.dto.ts

Index

Properties

Properties

Optional constraints
Type : Record<string | unknown>
Decorators :
@ApiPropertyOptional({description: 'Additional JSON schema constraints for this field', type: Object})
@IsOptional()
@IsObject()
Optional defaultValue
Type : unknown
Decorators :
@ApiPropertyOptional({description: 'Default value', oneOf: undefined})
@IsOptional()
Optional disclosable
Type : boolean
Decorators :
@ApiPropertyOptional({description: 'Whether claim is disclosable in SD-JWT'})
@IsOptional()
@IsBoolean()
Optional display
Type : FieldDisplayDto[]
Decorators :
@ApiPropertyOptional({type: () => })
@IsOptional()
@IsArray()
@ValidateNested({each: true})
@Type(undefined)
Optional mandatory
Type : boolean
Decorators :
@ApiPropertyOptional({description: 'Whether claim is mandatory'})
@IsOptional()
@IsBoolean()
Optional namespace
Type : string
Decorators :
@ApiPropertyOptional({description: 'Namespace for mDOC field', example: 'eu.europa.ec.eudi.pid.1'})
@IsOptional()
@IsString()
path
Type : Array<string | number | null>
Decorators :
@ApiProperty({description: 'Path to claim value', example: undefined, type: 'array', items: undefined})
@IsArray()
type
Type : "string" | "number" | "integer" | "boolean" | "object" | "array" | "date"
Decorators :
@ApiProperty({description: 'Claim value type', enum: undefined})
@IsString()
@IsIn(['string', 'number', 'integer', 'boolean', 'object', 'array', 'date'])
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { Type } from "class-transformer";
import {
    IsArray,
    IsBoolean,
    IsIn,
    IsObject,
    IsOptional,
    IsString,
    ValidateNested,
} from "class-validator";

export class FieldDisplayDto {
    @ApiProperty({
        description: "Locale code based on BCP47 (RFC 5646)",
        example: "en-US",
    })
    @IsString()
    locale!: string;

    @ApiProperty({ description: "Display name", example: "Given Name" })
    @IsString()
    name!: string;

    @ApiPropertyOptional({
        description: "Optional display description",
        example: "Primary first name",
    })
    @IsOptional()
    @IsString()
    description?: string;
}

export class ClaimFieldDefinitionDto {
    @ApiProperty({
        description: "Path to claim value",
        example: ["address", "locality"],
        type: "array",
        items: {
            oneOf: [{ type: "string" }, { type: "number" }, { type: "null" }],
        },
    })
    @IsArray()
    path!: Array<string | number | null>;

    @ApiProperty({
        description: "Claim value type",
        enum: [
            "string",
            "number",
            "integer",
            "boolean",
            "object",
            "array",
            "date",
        ],
    })
    @IsString()
    @IsIn(["string", "number", "integer", "boolean", "object", "array", "date"])
    type!:
        | "string"
        | "number"
        | "integer"
        | "boolean"
        | "object"
        | "array"
        | "date";

    @ApiPropertyOptional({
        description: "Default value",
        oneOf: [
            { type: "string" },
            { type: "number" },
            { type: "boolean" },
            { type: "object", additionalProperties: true },
            { type: "array", items: {} },
            { type: "null" },
        ],
    })
    @IsOptional()
    defaultValue?: unknown;

    @ApiPropertyOptional({ description: "Whether claim is mandatory" })
    @IsOptional()
    @IsBoolean()
    mandatory?: boolean;

    @ApiPropertyOptional({
        description: "Whether claim is disclosable in SD-JWT",
    })
    @IsOptional()
    @IsBoolean()
    disclosable?: boolean;

    @ApiPropertyOptional({
        description: "Namespace for mDOC field",
        example: "eu.europa.ec.eudi.pid.1",
    })
    @IsOptional()
    @IsString()
    namespace?: string;

    @ApiPropertyOptional({ type: () => [FieldDisplayDto] })
    @IsOptional()
    @IsArray()
    @ValidateNested({ each: true })
    @Type(() => FieldDisplayDto)
    display?: FieldDisplayDto[];

    @ApiPropertyOptional({
        description: "Additional JSON schema constraints for this field",
        type: Object,
    })
    @IsOptional()
    @IsObject()
    constraints?: Record<string, unknown>;
}

results matching ""

    No results matching ""