Download the PHP package harp-orm/validate without Composer

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

Harp Validate

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version

Harp Validate is a validation library. It generates errors for objects based on a predefined assertions.

Quick Example:

Errors

The result of $asserts->getErrors($subject) is actually an Errors object. It's an Iterator that holds all the erorrs and has ->humanize() mehtod to display all the errors. You can also foreach it and get all the errors separately. Casting it to string calls ->humanize() automatically.

You can also traverse through the Errors object using getFirst and getNext methods.

ValidateTrait

You can also add a special trait to an object to make it "validatable".

It will addd these methods to your class:

Method Description
validate() Perform the assertions, specified in the getValidationAsserts(). Will return true or false, and will set the errors object
getErrors() Returns an Errors object. If validate has not been called yet, will return an empty Errors object
isEmptyErrors() Return true or false
assertValid() Throw Harp\Validate\InvalidException if there are any errors

Available Asserts

Callback

Assert that the result of a given callback is true. You must use a closure object, and will recieve the subject and the value as arguments.

Email

Assert if the value is not a proper email address. uses a small and fast regex which should handle most cases.

EmailStrict

Assert if the value is not a proper email address. Uses a slower but more comprehensive check thane Email.

GreaterThan

Assert that the value is greater than a set length. Value can be int or float or even numeric string

InArray

Assert if the value is present in an array, uses a simple in_array call. Will throw InvalidArgumentException if the array is empty.

IP

Assert that the value's is a valid IP address uses filter_var() internally

IsInstanceOf

Assert if the value is an object of a given class is_a call. Will throw InvalidArgumentException if the class does not exist.

LengthBetween

Assert that the value's string length is between two set lengths (including). Uses mb_strlen() internally.

LengthEquals

Assert that the value is of exact string length. Uses mb_strlen() internally.

LengthGreaterThan

Assert that the value's string length is longer than a set length. Uses mb_strlen() internally.

LengthLessThan

Assert that the value's string length is shorter than a set length. Uses mb_strlen() internally.

LessThan

Assert that the value is less than a set length. Value can be int or float or even numeric string

Matches

Assert that a value of one property matches to the value of another

IsInteger

Assert that the value is a integer number.

IsFloat

Assert that the value is a float number.

Present

Assert if the value is empty

RegEx

Assert that the value matches a given regex. Passed directly to preg_match()

URL

Assert if the value is a valid url. Converts all UTF related charecters in the url to their proper encoding. It also will convert non-ASCII domain names, using "idn" if the "intl" extension is available. This is similar to what browsers normally do.

URLStrict

Assert if the value is a valid url. Uses php's filter_var() method.

AssertsTrait

This trait gives you the ability to easily add assertions to another object.

Here are all the methods added by this trait.

Method Description
getAsserts() Get the Asserts object
addAssert(AbstractAssertion) Add arbitrary asserts
assertCallback($name, $message) Add an Assert\Callback object
assertEmail($name, $message) Add an Assert\Email object
assertEmailStrict($name, $message) Add an Assert\EmailStrict object
assertGreaterThan($name, $value, $message) Add an Assert\GreaterThan object
assertInArray($name, $array, $message) Add an Assert\InArray object
assertIP($name, $message) Add an Assert\IP object
assertIsInteger($name, $message) Add an Assert\IsInteger object
assertIsInstanceOf($name, $class, $message) Add an Assert\IsInstanceOf object
assertIsFloat($name, $message) Add an Assert\IsFloat object
assertLengthBetween($name, $min, $max, $message) Add an Assert\LengthBetween object
assertLengthEquals($name, $length, $message) Add an Assert\LengthEquals object
assertLengthGreaterThan($name, $length, $message) Add an Assert\LengthGreaterThan object
assertLengthLessThan($name, $length, $message) Add an Assert\LengthLessThan object
assertLessThan($name, $value, $message) Add an Assert\LessThan object
assertMatches($name, $property, $message) Add an Assert\Matches object
assertPresent($name, $message) Add an Assert\Present object
assertRegEx($name, $pattern, $message) Add an Assert\RegEx object
assertURL($name, $message) Add an Assert\URL object
assertURLStrict($name, $message) Add an Assert\URLStrict object

License

Copyright (c) 2014, Clippings Ltd. Developed by Ivan Kerin as part of clippings.com

Under BSD-3-Clause license, read LICENSE file.


All versions of validate with dependencies

PHP Build Version
Package Version
No informations.
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 harp-orm/validate contains the following files

Loading the files please wait ....