2017 © Pedro Peláez
 

library config-schema

Schema builder for the weew/config package.

image

weew/config-schema

Schema builder for the weew/config package.

  • Sunday, August 28, 2016
  • by weew
  • Repository
  • 1 Watchers
  • 0 Stars
  • 73 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 0 % Grown

The README.md

Config Schema

Build Status Code Quality Test Coverage Version Licence, (*1)

Table of contents

Installation

composer require weew/config-schema, (*2)

Introduction

This package allows easy config validation and is used in combination with the weew/config package., (*3)

Usage

You can describe your config schema like this:, (*4)

$config = new Config([
    'some' => 'value',
    'items' => ['foo', 'bar'],
    'name' => 'John Doe',
]);
$schema = new ConfigSchema($config);

$schema
    ->hasValue('some')
    ->hasArray('items')->allowed(['foo', 'baz'])
    ->hasString('name')->min(3)->max(10)
;

After you've described your schema, you can either validate it, which will return you an instance of IValidationResult, or assert it, which will throw an exception., (*5)

$result = $schema->check();

foreach ($result->getErrors() as $error) {
    echo $error->getSubject() . ' ' . $error->getMessage();
}

// or

try {
    $schema->assert();
} catch (ConfigValidationException $ex) {
    $result = $ex->getValidationResult();
}

The Versions

28/08 2016

dev-master

9999999-dev

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

28/08 2016

v1.4.2

1.4.2.0

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

28/08 2016

v1.4.1

1.4.1.0

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

28/08 2016

v1.4.0

1.4.0.0

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

26/08 2016

v1.3.2

1.3.2.0

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

17/08 2016

v1.3.1

1.3.1.0

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

17/08 2016

v1.3.0

1.3.0.0

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

17/08 2016

v1.2.0

1.2.0.0

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

17/08 2016

v1.1.0

1.1.0.0

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott

17/08 2016

v1.0.0

1.0.0.0

Schema builder for the weew/config package.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Maxim Kott