Skip to content
Pieter Hordijk edited this page Dec 31, 2018 · 2 revisions

TOC

Exists

Validates the input (string) to be an existing ISBN number.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use Amp\Artax\DefaultClient;
use Amp\Redis\Client;
use HarmonyIO\Cache\Provider\Redis;
use HarmonyIO\HttpClient\Client\ArtaxClient;
use HarmonyIO\Validation\Rule\Isbn\Exists;

$httpClient = new ArtaxClient(new DefaultClient(), new Redis(new Client('tcp://127.0.0.1:6379')));

(new Exists($httpClient, 'google books api key'))->validate('9788970137506');

Note: The ISBN results are cached for 7 days.

Failure reasons

  • Type.String when the validated value is not a string
  • Isbn.Isbn when the validated value is not a valid ISBN number
  • Isbn.Exists when the ISBN number does not exists

Isbn

Validates the input (string) to be a valid ISBN number.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Isbn\Isbn;

(new Isbn())->validate('9788970137506');

Failure reasons

  • Type.String when the validated value is not a string
  • Isbn.Isbn when the validated value is not a valid ISBN number

Isbn10

Validates the input (string) to be a valid ISBN-10 number.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Isbn\Isbn10;

(new Isbn10())->validate('1566199093');

Failure reasons

  • Type.String when the validated value is not a string
  • Isbn.Isbn10 when the validated value is not a valid ISBN-10 number

Isbn13

Validates the input (string) to be a valid ISBN-13 number.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use HarmonyIO\Validation\Rule\Isbn\Isbn13;

(new Isbn13())->validate('9788970137506');

Failure reasons

  • Type.String when the validated value is not a string
  • Isbn.Isbn13 when the validated value is not a valid ISBN-13 number
Clone this wiki locally