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

This commit is contained in:
2022-06-09 01:21:21 +09:00
parent 40eda5477a
commit 30401382fd
+9 -2
View File
@@ -78,10 +78,17 @@ class DefaultConverter implements Converter
return $raw; return $raw;
} }
if($type === 'bool' && is_bool($raw)){ if($type === 'bool'){
if(is_bool($raw)){
$success = true; $success = true;
return $raw; return $raw;
} }
if($raw === 0 || $raw === 1){
$success = true;
return $raw !== 0;
}
}
return null; 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 public function convertTo(mixed $data): string|array|int|float|bool|null