-
Notifications
You must be signed in to change notification settings - Fork 770
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
715bf4b
commit 250fd93
Showing
16 changed files
with
111 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Property | ||
|
||
- `Property(string $name)` | ||
- `Property(string $name, Validatable $rule)` | ||
- `Property(string $name, Validatable $rule, bool $mandatory)` | ||
|
||
Validates an object property, even private ones. | ||
|
||
```php | ||
$obj = new stdClass; | ||
$obj->foo = 'bar'; | ||
|
||
v::property('foo')->validate($obj); // true | ||
``` | ||
|
||
You can also validate the property itself: | ||
|
||
```php | ||
v::property('foo', v::equals('bar'))->validate($obj); // true | ||
``` | ||
|
||
Third parameter makes the property presence optional: | ||
|
||
```php | ||
v::property('lorem', v::stringType(), false)->validate($obj); // true | ||
``` | ||
|
||
The name of this validator is automatically set to the property name. | ||
|
||
## Categorization | ||
|
||
- Nesting | ||
- Objects | ||
- Structures | ||
|
||
## Changelog | ||
|
||
Version | Description | ||
--------|------------- | ||
3.0.0 | Renamed from `Attribute` to `Property` | ||
0.3.9 | Created | ||
|
||
*** | ||
See also: | ||
|
||
- [Key](Key.md) | ||
- [KeyNested](KeyNested.md) | ||
- [ObjectType](ObjectType.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.