2017 © Pedro Peláez
 

library validate-filler

Fill forms generated by validate (JSON schema) specification

image

phramework/validate-filler

Fill forms generated by validate (JSON schema) specification

  • Thursday, March 15, 2018
  • by nohponex
  • Repository
  • 8 Watchers
  • 3 Stars
  • 2,681 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 7 Open issues
  • 6 Versions
  • 16 % Grown

The README.md

phramework/validate-filler

Fill forms generated by validate (JSON schema) specification, (*1)

Build Status Coverage Status, (*2)

Usage

Require package using composer, (*3)

composer require phramework/validate-filler

Example parsing schema from json

<?php
$validator = \Phramework\Validate\ObjectValidator::createFromJSON('{
  "type": "object",
  "properties": {
    "a": {
      "type": "string",
      "enum": [
        "1",
        "2",
        "3"
      ]
    },
    "b": {
      "type": "string",
      "enum": [
        "i",
        "ii",
        "iii"
      ]
    }
  },
  "required": ["a"]
}');

$value = (new \Phramework\ValidateFiller\Filler())
    ->fill($validator);

var_dump($value);

Sample outputs:, (*4)

class stdClass#1381 (1) {
  public $a =>
  string(1) "2"
}
class stdClass#1381 (2) {
  public $a =>
  string(1) "3"
  public $b =>
  string(2) "ii"
}
  • will always include property "a" since it's required
  • some times will include property "b" (probabilistic)

Example using ObjectValidator constructor

<?php
$validator = new \Phramework\Validate\ObjectValidator(
    (object) [
        'a' => new \Phramework\Validate\EnumValidator([
            '1',
            '2',
            '3'
        ]),
        'b' => new \Phramework\Validate\EnumValidator([
            'i',
            'ii',
            'iii'
        ])
    ],
    ['a'],
    false
);

$value = (new \Phramework\ValidateFiller\Filler())
    ->fill($validator);

Development

Install dependencies

composer update

Test and lint code

composer test
composer lint

Generate documentation

composer doc

License

Copyright 2015-2017 Xenofon Spafaridis, (*5)

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at, (*6)

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License., (*7)

The Versions

25/06 2017

dev-xs-container-experiment

dev-xs-container-experiment https://phramework.github.io/

Fill forms generated by validate (JSON schema) specification

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

25/06 2017