glebstar/sanitizer

Php7 package for json data validation

1.0.1 2020-11-04 14:17 UTC

This package is not auto-updated.

Last update: 2024-05-23 05:51:54 UTC


README

Package for transforms data according to filters

Install

composer require glebstar/sanitizer

Available filters

  • string
  • integer
  • float
  • phone

Examples

<?php

use Glebstar\Sanitizer\Sanitizer;

class Example
{
    public function testSanitize()
    {
        $sanitizer = new Sanitizer();
        $filters = [
            'foo' => 'integer',
            'bar' => 'string',
            'baz' => 'phone',
        ];
        $data = json_encode([
            'foo' => '123',
            'bar' => 'asd',
            'baz' => '8 (950) 288-56-23',
        ]);
    
        $result = $sanitizer->sanitize($filters, $data);
    }
}