schema_file = $file_path; if (\File::exists( $this->schema_file ) === false) { throw new \RuntimeException( 'Not Found json schema file: ' . $this->schema_file ); } } /** * Determine if the validation rule passes. * * @param string $attribute * @param mixed $value * @return bool */ public function passes($attribute, $value) { $validator = new Validator(); $data = \GuzzleHttp\json_decode( $value ); $validator->validate( $data, (object)[ '$ref' => 'file://' . $this->schema_file ] ); if ($validator->isValid()) { return true; } $this->errors = $validator->getErrors(); \Log::info($this->errors); return false; } /** * Get the validation error message. * * @return string */ public function message() { return 'json unvalid.'; } }