Skip to content

DataFormat

Pieter Hordijk edited this page Dec 30, 2018 · 1 revision

TOC

Json

Validates the input (string) to be a valid JSON string.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\DataFormat\Json;

(new Json())->validate('{"foo":"bar"}');

Failure reasons

  • Type.String when the validated value is not a string
  • DataFormat.Json when the validated value is not a valid JSON string
Clone this wiki locally