Skip to content

[12.x] Add Number::spelloutOrdinal() and format validation message to ordinal#53379

Closed
shaedrich wants to merge 5 commits intolaravel:masterfrom
shaedrich:format-validation-message-to-ordinal
Closed

[12.x] Add Number::spelloutOrdinal() and format validation message to ordinal#53379
shaedrich wants to merge 5 commits intolaravel:masterfrom
shaedrich:format-validation-message-to-ordinal

Conversation

@shaedrich
Copy link
Copy Markdown
Contributor

  • Number::ordinal(1) // 1st
  • 🆕 Number::spelloutOrdinal() // first

@shaedrich shaedrich changed the title [12.x] Format validation message to ordinal [12.x] Add Number::spelloutOrdinal() and format validation message to ordinal Nov 2, 2024
Comment on lines +430 to +433
return match ($value) {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10 => Number::spelloutOrdinal($value, 'en'),
default => 'other',
};
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of course, this could also be this:

Suggested change
return match ($value) {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10 => Number::spelloutOrdinal($value, 'en'),
default => 'other',
};
return match (true) {
$value >= 1 && $value <= 10 => Number::spelloutOrdinal($value, 'en'),
default => 'other',
};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or this:

Suggested change
return match ($value) {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10 => Number::spelloutOrdinal($value, 'en'),
default => 'other',
};
if ($value >= 1 && $value <= 10) {
return Number::spelloutOrdinal($value, 'en');
}
return 'other';

@taylorotwell
Copy link
Copy Markdown
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

@shaedrich
Copy link
Copy Markdown
Contributor Author

Delaying merging code for the upcoming version that won't come before the end of the year. Doesn't look like anyone's in a hurry …

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants