Change to using arrow functions (#1603)
* Change to using arrow functions Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Add lint rule --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -1,8 +1,7 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
|
||||
export function CastToBoolean() {
|
||||
return Transform(({ value }: { value: string }) => toBoolean(value));
|
||||
}
|
||||
export const CastToBoolean = () =>
|
||||
Transform(({ value }: { value: string }) => toBoolean(value));
|
||||
|
||||
const toBoolean = (value: any) => {
|
||||
if (typeof value === 'boolean') {
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
|
||||
export function CastToLogLevelArray() {
|
||||
return Transform(({ value }: { value: string }) => toLogLevelArray(value));
|
||||
}
|
||||
export const CastToLogLevelArray = () =>
|
||||
Transform(({ value }: { value: string }) => toLogLevelArray(value));
|
||||
|
||||
const toLogLevelArray = (value: any) => {
|
||||
if (typeof value === 'string') {
|
||||
|
||||
@ -1,8 +1,7 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
|
||||
export function CastToPositiveNumber() {
|
||||
return Transform(({ value }: { value: string }) => toNumber(value));
|
||||
}
|
||||
export const CastToPositiveNumber = () =>
|
||||
Transform(({ value }: { value: string }) => toNumber(value));
|
||||
|
||||
const toNumber = (value: any) => {
|
||||
if (typeof value === 'number') {
|
||||
|
||||
@ -13,8 +13,9 @@ export class IsAWSRegionConstraint implements ValidatorConstraintInterface {
|
||||
}
|
||||
}
|
||||
|
||||
export function IsAWSRegion(validationOptions?: ValidationOptions) {
|
||||
return function (object: object, propertyName: string) {
|
||||
export const IsAWSRegion =
|
||||
(validationOptions?: ValidationOptions) =>
|
||||
(object: object, propertyName: string) => {
|
||||
registerDecorator({
|
||||
target: object.constructor,
|
||||
propertyName: propertyName,
|
||||
@ -23,4 +24,3 @@ export function IsAWSRegion(validationOptions?: ValidationOptions) {
|
||||
validator: IsAWSRegionConstraint,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@ -14,8 +14,9 @@ export class IsDurationConstraint implements ValidatorConstraintInterface {
|
||||
}
|
||||
}
|
||||
|
||||
export function IsDuration(validationOptions?: ValidationOptions) {
|
||||
return function (object: object, propertyName: string) {
|
||||
export const IsDuration =
|
||||
(validationOptions?: ValidationOptions) =>
|
||||
(object: object, propertyName: string) => {
|
||||
registerDecorator({
|
||||
target: object.constructor,
|
||||
propertyName: propertyName,
|
||||
@ -24,4 +25,3 @@ export function IsDuration(validationOptions?: ValidationOptions) {
|
||||
validator: IsDurationConstraint,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@ -143,11 +143,11 @@ export class EnvironmentVariables {
|
||||
SENTRY_DSN?: string;
|
||||
}
|
||||
|
||||
export function validate(config: Record<string, unknown>) {
|
||||
export const validate = (config: Record<string, unknown>) => {
|
||||
const validatedConfig = plainToClass(EnvironmentVariables, config);
|
||||
|
||||
const errors = validateSync(validatedConfig);
|
||||
assert(!errors.length, errors.toString());
|
||||
|
||||
return validatedConfig;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user