Make auth module optional to conditionnaly load auth providers (#518)
* Make auth module optional to conditionnaly load auth providers * Fixes
This commit is contained in:
@ -0,0 +1,18 @@
|
||||
import { Transform } from 'class-transformer';
|
||||
|
||||
export function CastToBoolean() {
|
||||
return Transform(({ value }: { value: string }) => toBoolean(value));
|
||||
}
|
||||
|
||||
const toBoolean = (value: any) => {
|
||||
if (typeof value === 'boolean') {
|
||||
return value;
|
||||
}
|
||||
if (['true', 'on', 'yes', '1'].includes(value.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
if (['false', 'off', 'no', '0'].includes(value.toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
Reference in New Issue
Block a user