fix: DTO의 기본 converter에서 bool은 0,1 가능

This commit is contained in:
2022-06-09 01:21:21 +09:00
parent 40eda5477a
commit 30401382fd
+11 -4
View File
@@ -78,11 +78,18 @@ class DefaultConverter implements Converter
return $raw;
}
if($type === 'bool' && is_bool($raw)){
$success = true;
return $raw;
if($type === 'bool'){
if(is_bool($raw)){
$success = true;
return $raw;
}
if($raw === 0 || $raw === 1){
$success = true;
return $raw !== 0;
}
}
return null;
}
@@ -100,7 +107,7 @@ class DefaultConverter implements Converter
}
}
throw new \Exception('DefaultConverter can not convert');
throw new \Exception('DefaultConverter can not convert '.gettype($raw));
}
public function convertTo(mixed $data): string|array|int|float|bool|null