Skip to content

Commit d3048c4

Browse files
committed
Update readme, add badges. Begin to document available validation rules.
1 parent 021da40 commit d3048c4

File tree

1 file changed

+85
-13
lines changed

1 file changed

+85
-13
lines changed

README.md

Lines changed: 85 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
# Useful Laravel Validation Rules
2-
3-
Some useful Laravel validation rules.
1+
[![Scrutinizer coverage (GitHub/BitBucket)](https://img.shields.io/scrutinizer/coverage/g/f9webltd/laravel-validation-rules)]()
2+
[![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/f9webltd/laravel-validation-rules)]()
3+
[![Build Status](https://travis-ci.org/f9webltd/laravel-validation-rules.svg)](https://travis-ci.org/f9webltd/laravel-validation-rules)
4+
[![StyleCI Status](https://github.styleci.io/repos/266997689/shield)](https://github.styleci.io/repos/266997689)
5+
[![License](https://poser.pugx.org/f9webltd/laravel-validation-rules/license)](https://packagist.org/packages/f9webltd/laravel-validation-rules)
46

5-
## Available rules
7+
# Useful Laravel Validation Rules
68

7-
* Simple API
8-
* Laravel `>=5.8 | 6.x | 7.x` are supported
9-
* Render named, property type, raw, Twitter card and OpenGraph tags
10-
* Render default tags on every request
11-
* There is no need to set meta titles for every controller method. The package can optionally guess titles based on uri segments or the current named route
12-
* Well documented
9+
A collection of Laravel validation rules.
1310

1411
## Requirements
1512

16-
PHP >= 7.2, Laravel >= 5.8.
13+
PHP >= 7.2, Laravel `>=5.8 | 6.x | 7.x`.
1714

1815
## Installation
1916

2017
``` bash
21-
composer require f9webltd/laravel-meta
18+
composer require f9webltd/laravel-validation-rules
2219
```
2320

2421
The package will automatically register itself.
@@ -41,7 +38,82 @@ Alternatively use the rule directly with a [Laravel form request object](https:/
4138

4239
## Available rules
4340

44-
To follow ...
41+
- [`Base64EncodedString`](#base64encodedstring)
42+
- [`Coordinate`](#coordinate)
43+
- [`DomainRestrictedEmail`](#domainrestrictedemail)
44+
- [`EvenNumber`](#evennumber)
45+
- [`ExcludesHtml`](#excludeshtml)
46+
- [`HexColourCode`](#hexcolourcode)
47+
- [`Honorific`](#honorific)
48+
- [`IncludesHtml`](#includeshtml)
49+
50+
### `Base64EncodedString`
51+
52+
Ensure the passed attribute is a valid base 64 encoded string.
53+
54+
### `Coordinate`
55+
56+
Ensure the passed attribute is a valid comma separated Latitude and Longitude string. For example: `51.507877,-0.087732`.
57+
58+
### `DomainRestrictedEmail`
59+
60+
Ensure the passed email in question is part of the provided whitelist of domains.
61+
62+
For instance, to ensure the given email domain is `f9web.co.uk` or `laravel.com`:
63+
64+
```php
65+
use F9Web\ValidationRules\Rules\DomainRestrictedEmail;
66+
67+
// ...
68+
69+
$request->validate([
70+
'email' => [
71+
'required',
72+
(new DomainRestrictedEmail())->validDomains([
73+
'f9web.co.uk',
74+
'laravel.com',
75+
]),
76+
],
77+
]);
78+
```
79+
80+
The validation message will include the list of whitelisted domains based upon the provided configuration.
81+
82+
### `EvenNumber`
83+
84+
Ensure the passed attribute is an even number.
85+
86+
### `ExcludesHtml`
87+
88+
Ensure the passed attribute does not contain HTML.
89+
90+
### `HexColourCode`
91+
92+
Ensure the passed attribute is a valid hex colour code (three of six characters in length), optionally validating the presence of the `#` prefix.
93+
94+
Minimum usage example to validate a short length code with the prefix i.e. `#fff`:
95+
96+
```php
97+
use F9Web\ValidationRules\Rules\HexColourCode;
98+
99+
(new HexColourCode());
100+
```
101+
102+
Extended usage example to validate a long length code , omitting prefix i.e. `cc0000`:
103+
104+
```php
105+
use F9Web\ValidationRules\Rules\HexColourCode;
106+
107+
(new HexColourCode())->withoutPrefix()->longFormat();
108+
```
109+
110+
### `Honorific`
111+
112+
Ensure the passed attribute is a valid honorific, omitting appended dots. The list of valid honorifics is available [here](src/Support/Honorifics.php).
113+
114+
### `IncludesHtml`
115+
116+
Ensure the passed attribute contains HTML.
45117

46118
## Contribution
47119

0 commit comments

Comments
 (0)