Download the PHP package mizmoz/validate without Composer

On this page you can find all versions of the php package mizmoz/validate. 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 validate

Mizmoz / validate

Validation for PHP 7 that tries to suck less.

We've used a lot of different validation libraries over time and I've yet to be truly happy with any of them.

The main aim for this is to create a validator that can handle complex items, resolve them and also create nice descriptions of themselves. The dream is to create a validator that can handle REST API data, send useful error messages to the user and also a nice description of the endpoint. This will be the face of the Mizmoz API.

Table of Contents

Getting started

Composer installation

It's probably worth pointing out the API is really new and very likely to change.

Keeping the resources up to date

If you‘re using the IsEmailDisposable validator you‘ll want to make sure you‘re using an up to date list of disposable email host names.

Best practice is you create a cron job that executes the update below.

See the resources folder for an example cron file that should be placed in /etc/cron.d.

Basic validation

Resolving a validator to a new value

More complex and useful examples

Validate ACL

Whilst there are no validators for ACL (they might come later). There are exceptions that can be returned or thrown in your application. This way you can use a standard set of Exceptions to handle ACL failures. For example we use validation on our API and will catch the AclException to display an error message.

Testing

Any validator or resolver can be mocked using the ValidatorFactory::mock() method.

The mocking is pretty simple and just allows for the return Result object to be set by calling methods on the mock object.

Getting the parameters passed to the Mocked object

Validators

IsArray

Check the value is an array

IsArrayOf

Check the array contains only the provided values. Useful for checking enums that are allowed multiple values. For only 1 value set IsOneOf

IsArrayOfShape

Same as IsShape except the $value must be an array.

IsArrayOfType

Check the array contains only items of the particular type

Checking against a single type

Checking against multiple types

IsBoolean

Check the value is boolean-ish, that is 1, '1', true, 'true' & 0, '0', false, 'false'.

IsDate

Check the value is a valid date in the format provided.

$options

IsEmailDisposable

Check if the value is a disposable email address like guerillamail.com etc

IsEmail

Check if the value is a valid email address

Don‘t allow disposable email addreses

IsFilter

The filter is a pretty cool helper for parsing strings for filtering.

Basic hash tags with example usage

We use the filter to map to column names for things like statuses etc. Only @tag & #tag are supported anything else will be returned in the filter key as plain text

Special :isInteger tagging

The filter value has any tags removed

Default tags when no tags are present using the *

Defaults are for the defined group so you can have other tags without defaults

IsInteger

Check the value is an integer

bool $strict - set to strict to only allow integers and not number strings or floats.

IsNumeric

Check the value is a number

IsObject

IsOneOf

IsOneOfType

IsReCaptcha

Validate a reCAPTCHA response

IsRequired

IsSame

IsShape

Check the value is a particular shape, sometimes is easier to explain with an example...

Shapes can be nested to validate shapes of shapes.

Using the Validate::set() provides a helper to return nice descriptions of the shape.

IsString

Check the value is a string

Road map

On the todo list

Tasks

General

Allow positive or negative matching. Possibly like this:

Validators

IsPassword

Check a string matches the requirements for the password.

Resolvers

ToHash

Create a hash of the given data with various techniques. MD5, SHA1, password_hash etc.

Generate API releases

At Mizmoz we already use the validator chain to generate our API schema in JSON.

The next step would be to create new versions or releases by comparing the new and old API endpoints. This would allow us to create discrete versions for each change and also help with documentation by highlighting each of the changes. We could even go further and highlight breaking changes to the API when defaults etc are changed.


All versions of validate with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
ext-intl Version >=1.1
ext-json Version >=1.2
symfony/console Version ^7.0
guzzlehttp/guzzle Version ^7.9
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 mizmoz/validate contains the following files

Loading the files please wait ....