Commit graph

5 commits

Author SHA1 Message Date
Henrique Moody d36572cc25
Split the "Property" rule
Currently, the Property rule has a third parameter that allows the
validation of the wrapped rule to be optional, meaning that the
validation will only happen if the property exists. That parameter makes
the rule harder to understand at times.

I'm splitting the Property rule into Property, PropertyExists, and
PropertyOptional. That way, it becomes apparent when someone wants only
to validate whether a property exists or if they will validate the value
of the property only when it exists.

I deliberately didn't create an abstract class because those rules are
different enough not to have an abstraction. In fact, I can see myself
deleting the AbstractRelated after I refactor the KeyNested rule.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-05 00:48:31 +01:00
Henrique Moody 3a7ac0240d
Make clear when Stub should not be executed
Having a named constructor with a name that clarifies that we don't
expect to execute the stub will make it easier to read the tests.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-02-22 16:15:29 +01:00
Henrique Moody b1555fb0cd
Use a single line to describe return type
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-02-04 20:04:40 +01:00
Henrique Moody a3c1602351
Use "Stub" instead of mocking "Validatable"
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-02-04 19:56:12 +01:00
Henrique Moody 250fd93682
Rename "Attribute" rule to "Property"
Because now we have the concept of attributes in PHP, the rule with the
name "Attribute" makes no sense because it doesn't validate attributes
but properties.

In the future, it might be possible that Validation will have a rule
called "Attribute" to validate PHP attributes.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-01-28 15:07:42 +01:00
Renamed from tests/unit/Rules/AttributeTest.php (Browse further)