Last active
August 19, 2018 21:51
Revisions
-
aaronpk revised this gist
Aug 19, 2018 . No changes.There are no files selected for viewing
-
aaronpk created this gist
Aug 19, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ <?php function is_valid_mf2_json($input) { // Input to this function must be an array if(!is_array($input)) return false; // Keys type and properties are required at a minimum and must be arrays if(!isset($input['type']) || !is_array($input['type'])) return false; if(!isset($input['properties']) || !is_array($input['properties'])) return false; // Every value of type must be a string beginning with h- foreach($input['type'] as $type) { if(!is_string($type) || substr($type, 0, 2) != 'h-') return false; } foreach($input['properties'] as $property) { // Every property must be an array if(!is_array($property)) return false; // If a value of a property is not a string, it must be a valid mf2 object foreach($property as $val) { if(!is_string($val)) { if(!is_valid_mf2_json($val)) return false; } } } return true; }