Skip to content

Commit

Permalink
Add badge to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
assertchris committed Mar 19, 2019
1 parent fac3ff1 commit bddc26e
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Prop Types

[![Support on Gitstore](https://enjoy.gitstore.app/repositories/badge-preprocess/pre-prop-types.svg)](https://enjoy.gitstore.app/repositories/preprocess/pre-prop-types)

This is a PHP take on the ReactJS Prop Types checking. I made it because I wanted an easier way to validate the type and presence of properties in Phpx components.

## Getting started
Expand Down Expand Up @@ -51,18 +53,18 @@ try {
}
```

- `isRequired` will ensure the value is present in the accompanying properties array
- `either` allows one or more types (preferably two distinct types) for comparison
- `isRequired` will ensure the value is present in the accompanying properties array
- `either` allows one or more types (preferably two distinct types) for comparison

There are also variations on these:

- `PropTypes::array()` expects any array values, without a specific type
- `PropTypes::boolean()` is the same as `PropTypes::bool()`
- `PropTypes::integer()` is the same as `PropTypes::int()`
- `PropTypes::double()` expects double values
- `PropTypes::iterable()` expects any iterable values
- `PropTypes::numeric()` expects any numeric values
- `PropTypes::object()` expects any object values, without a specific type
- `PropTypes::array()` expects any array values, without a specific type
- `PropTypes::boolean()` is the same as `PropTypes::bool()`
- `PropTypes::integer()` is the same as `PropTypes::int()`
- `PropTypes::double()` expects double values
- `PropTypes::iterable()` expects any iterable values
- `PropTypes::numeric()` expects any numeric values
- `PropTypes::object()` expects any object values, without a specific type

## Validating types

Expand All @@ -72,7 +74,8 @@ We don't automatically validate props – this must be done by the consumer. And
use Pre\PropTypes;
use function Pre\Phpx\Html\render as renderHTML;

function render($type, $props = []) {
function render($type, $props = [])
{
$props = (array) $props;

if (class_exists($type)) {
Expand Down

0 comments on commit bddc26e

Please sign in to comment.