Download the PHP package linna/filter without Composer

On this page you can find all versions of the php package linna/filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package filter



[![Build Status](https://travis-ci.org/linna/filter.svg?branch=master)](https://travis-ci.org/linna/filter) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/linna/filter/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/linna/filter/?branch=master) [![Code Coverage](https://scrutinizer-ci.com/g/linna/filter/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/linna/filter/?branch=master) [![StyleCI](https://styleci.io/repos/111321128/shield?branch=master&style=flat)](https://styleci.io/repos/111321128) [![PHP 7.2](https://img.shields.io/badge/PHP-7.2-8892BF.svg)](http://php.net)

About

This package provide filters for validate and sanitize user input data.

Requirements

This package require php 7.2

Installation

With composer:

Available Filters

Filters

Rule Name Aliases Description Rule Arguments Operators Example Data from $_POST Example Rule
date dat, d check for a valid date 1 none ['born'] = '1980-06-01' 'born: date Y-m-d'
datecompare datcmp, dc compare one date with another 3 >, <, >=, <=, = ['born'] = '1980-06-01' 'born: datecompare < Y-m-d 1990-01-01'
email mail, e@ check for a valid email 0 none ['email'] = '[email protected]' 'email: email'
escape escp, es convert special chars in html entities 0 none ['name'] = 'foo<script>' 'name: escape'
ip ip check for a valid ip (ipv4 and ipv4) 0 none ['host'] = 192.168.0.1 'host: ip'
iprange iprng, ipr check if provided ipv4 or ipv6 is in CIDR range 1 none ['host'] = 192.168.0.1 'host: iprange 192.168.0.1/24'
number num, n check for a valid number and cast to number 0 none ['age'] = 25 'age: number'
numbercompare numcmp, nc compare one number with another 2 >, <, >=, <=, = ['age'] = 25 'age: numbercompare > 18'
numberinterval numint, ni check if a number is included or not on interval 3 <>, ><, <=>, >=< ['age'] = 25 'age: numberinterval >< 18 80'
required req, rq check for null values 0 none ['name'] = 'foo' 'name: required'
str string, s cast to string 0 none ['name'] = 'foo' 'name: str'
stringlencompare strlencmp, strlen, slc check the length of a string 2 >, <, >=, <=, =, != ['name'] = 'foo' 'name: stringlencompare > 2'

A rule could be called with the name or with the alias. An alias help to write rules more quickly.

Operators

Rule Name Operator Description Notes
DateCompare < less than
> greater than
<= less than or equal
>= greater than or equal
= equal PHP === equal
NumberCompare < less than
> greater than
<= less than or equal
>= greater than or equal
NumberInterval <> out interval, exclusive 8-10: 7, 11 true - 8, 9, 10 false
>< in interval, exclusive 8-10: 9 true - 7, 8, 10, 11 false
<=> out interval, inclusive 8-10: 7, 8, 10, 11 true - 9 false
>=< in interval, inclusive 8-10: 8, 9, 10 true - 7, 11 false
StringLenCompare < length less than PHP strlen(string) < number
> length greater than PHP strlen(string) > number
<= length less than or equal PHP strlen(string) <= number
>= length greather than or equal PHP strlen(string) >= number
= length equal PHP strlen(string) === number
!= length not equal PHP strlen(string) !== number

Type of filters

Filters can be of two types: Validation filters or Sanitization filters. Validation filters check only if the data respect a certain criterion, instead sanitization filters alter passed data to make them conform to a given rule.

In this package are sanitization filters only Number and Escape

Note: For security reasons a Validation filter should be preferred, don't try to sanitize a bad user input, discard it!

Usage

Filters can be used in two different ways.

Filter one field

Apply one or more rules to one value:

Filter multiple fields

Apply one or more rules to many values, it is useful for validating forms:

Retriving results

There are two ways for get results from filter.

Using methods from Filter instance.

Using result object:

Rule syntax

Parser can accept rules formatted in varius way.

First word must be the name of the input, same present as index in input array.

Can be used for separate the words and params of rules this chars: : ; ,

Input name separator :

Input name separator : Rules separator ,

Input name separator : Rules separator ; Rule arguments separator ,

Must be used for params that contain spaces one of this chars: " '

Custom Rules

Custom rules give the possibility of expand the filter predefined ruleset.

Validate

Sanitize

Custom Rule should have:

And for callback function:

Note: For implementing a sanitize custom rule, closure must have only one argument and this argument must be passed for reference.


All versions of filter with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package linna/filter contains the following files

Loading the files please wait ....