nestjs-class-transformers 1.1.0
Install from the command line:
Learn more about npm packages
$ npm install @algoan/nestjs-class-transformers@1.1.0
Install via package.json:
"@algoan/nestjs-class-transformers": "1.1.0"
About this version
Extends class-transformers package with additional features.
npm install --save @algoan/nestjs-class-transformers
import { EnumFallback } from '@algoan/nestjs-class-transformers';
export enum UserRole {
ADMIN = 'ADMIN',
READER = 'READER',
}
class User {
@EnumFallback({
type: UserRole,
fallback: (value: UserRole) => UserRole.READER // if the role is not "ADMIN" or "READER", then the role will be "READER".
})
public role?: UserRole;
}
It works with array too:
import { EnumFallback } from '@algoan/nestjs-class-transformers';
export enum UserRole {
ADMIN = 'ADMIN',
READER = 'READER',
}
class User {
@EnumFallback({
type: UserRole,
fallback: (value: UserRole) => UserRole.READER // if an array element is not "ADMIN" or "READER", then the role will be "READER".
})
public roles: UserRole[];
}
Details
- nestjs-class-transformers
- algoan
- about 1 year ago
- ISC
- 1 dependencies
Assets
- nestjs-class-transformers-1.1.0.tgz
Download activity
- Total downloads 3,376
- Last 30 days 161
- Last week 41
- Today 0