Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[11.x] Add support for granular messages on Dimensions rule #52707

Closed
wants to merge 22 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2a8f35f
fix(dimensions): add properties to hold constraint values
CamKem Sep 6, 2024
c39a038
fix(dimensions): update constructor to call methods
CamKem Sep 6, 2024
cb46dd6
fix(dimensions): add new constraint methods & update existing to use …
CamKem Sep 6, 2024
04aaa29
fix(dimensions): build the validation rules and methods for data & va…
CamKem Sep 6, 2024
67b8991
fix(dimensions): add granular validation message translation strings
CamKem Sep 6, 2024
fcfd82b
fix(dimensions): add replace methods for granular rules
CamKem Sep 6, 2024
18b5652
fix(dimensions): cleanup additional methods on dimensions
CamKem Sep 6, 2024
1308f47
fix(dimensions): add methods for to ValidatesAttributes for validatin…
CamKem Sep 6, 2024
3948899
test: added one for each of the methods on the dimensions rule
CamKem Sep 6, 2024
c1ea328
test: add method for string format of the rule
CamKem Sep 6, 2024
8bee70f
test: added one for macroable trait
CamKem Sep 6, 2024
7ea1e5c
test: update expected validation messages for granularity on image fi…
CamKem Sep 6, 2024
6128096
chore: cleanup obsolete constructor
CamKem Sep 7, 2024
a2d280f
fix: add properties for the between rules & building rules
CamKem Sep 7, 2024
3b719bc
fix: add default callback & custom rule merges
CamKem Sep 9, 2024
8ddc78a
fix: use existing min, max & between replacement methods
CamKem Sep 9, 2024
868bac0
fix: styleci
CamKem Sep 9, 2024
5812d03
fix: styleci
CamKem Sep 9, 2024
3809876
Merge branch 'refs/heads/11.x' into feat/granular-dimension-messages
CamKem Sep 9, 2024
320f24c
stylci
CamKem Sep 11, 2024
7d47d87
fix: merge regression
CamKem Sep 17, 2024
054b1dd
test: coverage for constraints passed into the constructor via Rule c…
CamKem Sep 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'refs/heads/11.x' into feat/granular-dimension-messages
# Conflicts:
#	src/Illuminate/Validation/Concerns/ValidatesAttributes.php
#	src/Illuminate/Validation/Rules/Dimensions.php
#	tests/Validation/ValidationDimensionsRuleTest.php
CamKem committed Sep 9, 2024
commit 38098760c4fdb88ae60712c24b0be839b61d648f
42 changes: 0 additions & 42 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
@@ -1090,48 +1090,6 @@ private function failsMaxRatioCheck($parameters, $width, $height)
return ($width / $height) < $parameters['max_ratio'];
}

/**
* Determine if the given parameters fail a dimension minimum ratio check.
*
* @param array<string,string> $parameters
* @param int $width
* @param int $height
* @return bool
*/
private function failsMinRatioCheck($parameters, $width, $height)
{
if (! isset($parameters['min_ratio'])) {
return false;
}

[$minNumerator, $minDenominator] = array_replace(
[1, 1], array_filter(sscanf($parameters['min_ratio'], '%f/%d'))
);

return ($width / $height) > ($minNumerator / $minDenominator);
}

/**
* Determine if the given parameters fail a dimension maximum ratio check.
*
* @param array<string,string> $parameters
* @param int $width
* @param int $height
* @return bool
*/
private function failsMaxRatioCheck($parameters, $width, $height)
{
if (! isset($parameters['max_ratio'])) {
return false;
}

[$maxNumerator, $maxDenominator] = array_replace(
[1, 1], array_filter(sscanf($parameters['max_ratio'], '%f/%d'))
);

return ($width / $height) < ($maxNumerator / $maxDenominator);
}

/**
* Validate an attribute is unique among other values.
*
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Rules/Dimensions.php
Original file line number Diff line number Diff line change
@@ -143,7 +143,7 @@ class Dimensions implements Rule, DataAwareRule, ValidatorAwareRule
*/
public function width($value)
{
$this->width = $value;
$this->constraints['width'] = $value;

return $this;
}
You are viewing a condensed version of this merge commit. You can view the full changes here.