Validate the attribute is a valid JSON string.

@param  mixed $value

@return bool
501391
public function isJson($value)
    {
        if (!is_scalar($value) && !method_exists($value, '__toString')) {
            return false;
        }

        json_decode($value);

        return json_last_error() === JSON_ERROR_NONE;
    }
985164
public function validate($value)
    {
        return is_string($value) ? Ok::unit() : Error::unit([ Error::NON_STRING ]);
    }
233555
public function isValid($value) : bool
    {
        if ($value === null && $this->nullable) {
            return true;
        }

        return is_array($value);
    }
582838
protected function validate($value)
    {
        $parsedValue = $this->parsevalue($value);
        if ($parsedValue === false) {
            $this->messenger->add(new StringType('Value cannot be mapped'));
        }

        $ret = $this->rValidate($parsedValue, $this->typeMap, $value);
        if (!$ret) {
            $this->messenger->add(new StringType('Value has invalid type map'));
        }

        return $ret;
    }
1280346
public function isValueValid($value) {
		return $value instanceof Type\ProductType || $value instanceof DataType\TextType || $value instanceof DataType\URLType;
	}
570722
public function isValid($value)
    {
        foreach ((array) $value as $val) {
            if (\MUtil_String::contains($val, $this->_options[0])) {
                return true;
            }
        }
        return false;
    }
629453
protected function isValid($value)
    {
        if (is_null($value) || $value === '') {
            return;
        }

        if (is_string($value) === false || file_exists($value) === false || is_file($value) === false) {
            $valueMessage = is_string($value) ? sprintf('"%s"', $value) : 'The given value';
            $this->addError($valueMessage . ' is no valid resource-path', 1515053653);
        }
    }
1199376
public function validateToken($value) : bool
    {
        if (!is_string($value)) {
            return false;
        }

        return $this->getCSRFToken()->isValid($value);
    }
1060467
public function isValueValid($value) {
		return $value instanceof Type\ListItemType || $value instanceof DataType\TextType || $value instanceof Type\ThingType;
	}
1257041
public function isValueValid($value) {
		return $value instanceof Type\CreativeWork || $value instanceof Type\HowToSection || $value instanceof Type\HowToStep || $value instanceof DataType\TextType;
	}
1140104
public function validate($value) {
        return (string)$value == (string)$this->filter($value) ? $value : Filter::ERR_INVALID;
    }
328994
public static function validate($value)
    {
        $value = Utils::toString($value);
        $tags = [
            'latest', 'earliest', 'pending'
        ];

        return in_array($value, $tags);
    }
380342
public static function isJsonEncodable($value): bool
    {
        if ($value === null || is_scalar($value) || is_array($value)) {
            return true;
        }

        if (is_object($value) && ($value instanceof JsonSerializable)) {
            return true;
        }

        return false;
    }
408918
public function validate($value = "")
    {
        if (is_null($value) && $this->isEmptyAllowed()) {
            return true;
        }

        if ($this->isNullNotAllowed() && is_null($value)) {
            return false;
        }

        return true;
    }
441900
protected function parseAsJson($value)
    {
        if (is_string($value)) {
            $value = json_decode($value, true);
            $error = json_last_error();
            if ($error !== JSON_ERROR_NONE) {
                switch ($error) {
                    case JSON_ERROR_DEPTH:
                        $message = 'Maximum stack depth exceeded';
                        break;
                    case JSON_ERROR_STATE_MISMATCH:
                        $message = 'Underflow or the modes mismatch';
                        break;
                    case JSON_ERROR_CTRL_CHAR:
                        $message = 'Unexpected control character found';
                        break;
                    case JSON_ERROR_SYNTAX:
                        $message = 'Syntax error, malformed JSON';
                        break;
                    case JSON_ERROR_UTF8:
                        $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
                        break;
                    default:
                        $message = 'Unknown error';
                        break;
                }

                throw new InvalidArgumentException(sprintf(
                    'Value "%s" could not be parsed as JSON: "%s"',
                    is_object($value) ? get_class($value) : gettype($value),
                    $message
                ));
            }
        }

        return $value;
    }
1321518
public function sanitize($value)
    {
        if(!$value instanceof ObjectConfigJson)
        {
            if(is_string($value)) {
                $value = $this->getObject('object.config.factory')->fromString('json', $value);
            } else {
                $value = $this->getObject('object.config.factory')->createFormat('json', $value);
            }
        }

        return $value;
    }
662503
public function isValid($value)
    {
        if (!is_string($value)) {
            $this->_error(self::INVALID);
            return false;
        }

        $this->_setValue($value);

        if ('' === $value) {
            $this->_error(self::STRING_EMPTY);
            return false;
        }

        if (null === self::$_filter) {
            /**
             * @see Zend_Filter_Alpha
             */

            self::$_filter = new Zend_Filter_Alpha();
        }

        self::$_filter->allowWhiteSpace = $this->allowWhiteSpace;

        if ($value !== self::$_filter->filter($value)) {
            $this->_error(self::NOT_ALPHA);
            return false;
        }

        return true;
    }