Skip to content

Commit 8bbb632

Browse files
added Raw data type
1 parent 5bb2583 commit 8bbb632

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,10 @@ config_form(
138138
- It's a function and you don't need to `echo`
139139
- Use anywhere inside your HTML form
140140

141-
```php
141+
```html
142142
csrf();
143+
144+
<input type="hidden" name="_token" value="efef4c9360f26848f0d102b478e51859cfce4c9b197eb9d6473abfcaa2c6da38">
143145
```
144146
![Sample Csrf Form Input](https://raw.githubusercontent.com/tamedevelopers/validator/main/getErrorMessage.png)
145147

@@ -278,6 +280,7 @@ $form->rules([
278280
| string | s | `String` data validation |
279281
| html | - | `html` CMS/Blog content validation |
280282
| dev | - | `dev` CMS/Blog/Dev like content validation |
283+
| raw | - | `raw` Collect content without validation |
281284
| str_len | sl | `String Length` validation |
282285
| enum | en | `Enum` Forms `checkbox \| radio` or any form data that normally has no value when not checked |
283286
| array | a | `Array` data validation |

src/Methods/Datatype.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Datatype {
1919
private const RULE_BOOL = ['bool', 'b'];
2020
private const RULE_ENUM = ['enum', 'en', 'enm'];
2121
private const RULE_HTML = ['html'];
22+
private const RULE_RAW = ['raw'];
2223
private const RULE_DEV = ['dev'];
2324

2425
/**
@@ -180,6 +181,11 @@ protected static function validateFormInput(array $rulesData)
180181
$sanitized = Purify::html((string) $value);
181182
return (empty($sanitized) && $sanitized !== '0') ? false : $sanitized;
182183

184+
// ---------------- Raw ----------------
185+
case in_array($ruleFlag, self::RULE_RAW, true):
186+
$sanitized = Purify::raw((string) $value);
187+
return (empty($sanitized) && $sanitized !== '0') ? false : $sanitized;
188+
183189
// ---------------- DEV ----------------
184190
case in_array($ruleFlag, self::RULE_DEV, true):
185191
$sanitized = Purify::dev((string) $value);

0 commit comments

Comments
 (0)