Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds valid_json which is using json_last_error() === JSON_ERROR_NONE #1187

Merged
merged 3 commits into from
Sep 4, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions system/Validation/FormatRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@ public function valid_base64(string $str = null): bool

//--------------------------------------------------------------------

/**
* Valid JSON
*
* @param string
*
* @return bool
*/
public function valid_json(string $str = null): bool
{
json_decode($str);
return json_last_error() === JSON_ERROR_NONE;
}

//--------------------------------------------------------------------

/**
* Checks for a correctly formatted email address
*
Expand Down