Skip to content

Conversation

@henriquemoody
Copy link
Member

Since I updated the validation engine1, it became possible to create results with siblings. This commit changes the "Length", allowing it to create a result with a sibling when possible. That will improve the clarity of the error messages.

@henriquemoody henriquemoody added this to the 3.0 milestone Dec 11, 2024
@henriquemoody henriquemoody changed the title Update Length to generate results with siblings Update Length to generate results with a subsequent Dec 16, 2024
Since I updated the validation engine[1], it became possible to create
results with subsequents[2]. This commit changes the "Length", allowing
it to create a result with a subsequent only when it's possible. That
will improve the clarity of the error messages.

[1]: 238f2d5
[2]: 52e628f
@codecov
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.56%. Comparing base (6e3ed79) to head (aa293de).
Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1485      +/-   ##
============================================
+ Coverage     96.54%   96.56%   +0.01%     
- Complexity      973      977       +4     
============================================
  Files           201      201              
  Lines          2403     2414      +11     
============================================
+ Hits           2320     2331      +11     
  Misses           83       83              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@henriquemoody henriquemoody changed the title Update Length to generate results with a subsequent Only create Length with subsequents when it's possible Dec 16, 2024
@henriquemoody henriquemoody merged commit aa293de into Respect:main Dec 16, 2024
8 checks passed
@henriquemoody henriquemoody deleted the rule/length branch December 16, 2024 20:52
@henriquemoody henriquemoody mentioned this pull request Dec 16, 2024
74 tasks
- O comprimento de 0 deve possuir de 2 a 15 caracteres
- 0 deve ser um número de telefone válido para o país Estados Unidos
- Todas as regras requeridas devem passar para `[]`
- `[]` deve ser uma string
Copy link
Member Author

Choose a reason for hiding this comment

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

I changed this just because it was wrong, but it doesn't have anything to do with the changes.

));

test('Chained wrapped rule', expectAll(
fn() => v::length(v::between(5, 7)->odd())->assert([]),
Copy link
Member Author

Choose a reason for hiding this comment

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

This is pretty much the essence of the changes.

If you see the other tests, length() receives only 1 rule, this test receives two rules, and the two of them fail. That means that we can't simply add the prefix ("The length of") to the result of that rule because the result has two children.

When Length receives a rule that produces a result with children, we need to add the prefix ("The length of") to all the children of that result.

Copy link
Member Author

Choose a reason for hiding this comment

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

@dmjohnsson23 I wrote some comments to this merge request. If you have any questions, you can just write here, I'll be happy to answer them!

// Message: The length of "rose" must not be equal to 4
```

### `Length::TEMPLATE_WRONG_TYPE`
Copy link
Member Author

Choose a reason for hiding this comment

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

Because this is a new template, I had to add it to the documentation.

$length = $this->extractLength($input);
if ($length === null) {
return Result::failed($input, $this, [], self::TEMPLATE_WRONG_TYPE)
->withId('length' . ucfirst($this->rule->evaluate($input)->id));
Copy link
Member Author

Choose a reason for hiding this comment

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

This is just a way to get the id of the result

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant