Skip to content

Commit

Permalink
Merge pull request #37 from robertogallea/add_configurable_labels_and…
Browse files Browse the repository at this point in the history
…_date_format

Add configurable labels and date format
  • Loading branch information
robertogallea authored Oct 25, 2021
2 parents fb2c930 + 7dc1fc3 commit 14118c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/CodiceFiscaleGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ protected function _calcolaDataNascita()

$mm = $this->_mesi[$mese];

$gg = (strtoupper($this->sesso) == config('codicefiscale.labels.male')) ? $giorno : $giorno + 40;
$gg = ($this->sesso == config('codicefiscale.labels.male')) ? $giorno : $giorno + 40;
$gg = str_pad($gg, 2, '0', STR_PAD_LEFT);

return $aa.$mm.$gg;
Expand Down
19 changes: 19 additions & 0 deletions tests/CodiceFiscaleConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,23 @@ public function configChange()
['RSSMRA95E05F205Z', 'codicefiscale.date-format', 'd/m/Y', Carbon::parse('1995-05-05'), 'birthdate'],
];
}

/** @test */
public function it_can_require_cf_validation_against_form_fields_with_overridded_gender_labels()
{
$rules = [
'cf_field' => 'codice_fiscale:first_name=first_name,last_name=last_name,birthdate=birthdate,place=place',
];

$data = [
'cf_field' => 'RSSMRA80A01F205X',
'first_name' => 'Mario',
'last_name' => 'Rossi',
'birthdate' => '1980-01-01',
'place' => 'Milano',
];

$validator = $this->app['validator']->make($data, $rules);
$this->assertEquals(false, $validator->passes());
}
}

0 comments on commit 14118c0

Please sign in to comment.