Skip to content

Commit

Permalink
validate birthdate (#24)
Browse files Browse the repository at this point in the history
* fix translations

* remove duplicate translations

* validate birthdate
  • Loading branch information
marek657 authored Oct 15, 2023
1 parent cb997a0 commit 9b0952f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Entity/EuropeanCV.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,8 +573,18 @@ public function setDay(?int $day): self
return $this;
}

#[Assert\Date(message: 'trexima_european_cv.birth_date.constraint.valid_date')]
public function getBirthDate(): ?string
{
if (($year = $this->getYear()) && ($month = $this->getMonth()) && ($day = $this->getDay())) {
return $year . '-' . str_pad($month, 2, '0', STR_PAD_LEFT) . '-' . str_pad($day, 2, '0', STR_PAD_LEFT);
}

return null;
}

#[Assert\LessThanOrEqual('today', message: 'trexima_european_cv.birth_date.constraint.less_than_or_equal')]
public function getBirthDate(): ?\DateTimeImmutable
public function getBirthDateTime(): ?\DateTimeImmutable
{
if (($year = $this->getYear()) && ($month = $this->getMonth()) && ($day = $this->getDay())) {
return (new \DateTimeImmutable())->setDate($year, $month, $day)->setTime(0, 0);
Expand Down
6 changes: 6 additions & 0 deletions translations/validators+intl-icu.sk-SK.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,11 @@
<target>Príď si urobiť životopis až po narodení &#x1f60a; Prosím, skontroluj dátum narodenia.</target>
</segment>
</unit>
<unit id="tXD_L.h" name="trexima_european_cv.birth_date.constraint.valid_date">
<segment>
<source>trexima_european_cv.birth_date.constraint.valid_date</source>
<target>Prosím, vyplň dátum narodenia v správnom tvare.</target>
</segment>
</unit>
</file>
</xliff>

0 comments on commit 9b0952f

Please sign in to comment.