UNPKG

nestjs-appwrite

Version:

Easier Appwrite integration for your NestJS application.

31 lines (26 loc) 809 B
import 'reflect-metadata'; import typeMetadataStorage from '../../storage/type-metadata.storage'; import { determineRequiredValue, PropOptions } from './prop.options'; const DEFAULT_MIN = Number.MIN_VALUE; const DEFAULT_MAX = Number.MAX_VALUE; export type FloatPropOptions = PropOptions<number> & { isArray?: boolean; min?: number; max?: number; }; export function FloatProp(options: FloatPropOptions = {}): PropertyDecorator { return (target, propertyKey) => { const propKey = propertyKey.toString(); typeMetadataStorage.addPropertyMetadata( target.constructor, propKey, { ...options, required: determineRequiredValue(options), type: Number, min: options.min ?? DEFAULT_MIN, max: options.max ?? DEFAULT_MAX, } ); }; }