Download the PHP package lfbn/base-model without Composer
On this page you can find all versions of the php package lfbn/base-model. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lfbn/base-model
More information about lfbn/base-model
Files in lfbn/base-model
Package base-model
Short Description This is a Base Model that can be extended to define Models. It helps handling data validation, and extracting data.
License MIT
Homepage https://github.com/lfbn/base-model
Informations about the package base-model
About Base Model
- Features
- Installation
- Examples
This is a Base Model that can be extended to define Models. It helps handling data validation, and data conversion.
Features
- Validation of properties. All, except the isNotEmpty, doesn't validate the data if it is empty. The following validator are available:
- isNotEmpty
- isNumeric
- isInteger
- isFloat
- isString
- isBoolean
- isTrue
- isFalse
- isNull
- isNotNull
- isArray
- isEmail
- Model to array and JSON, preserving hidden attributes.
- Define attributes using arrays of data.
- Can define, when validation fails, if an exception is thrown.
- Can define if data should be validated or not.
Installation
Examples
How to use it
Define your model extending the AbstractBaseModel, then implement a public method getValidationRules. This method should define the properties you want to validate.
Here is an example:
How to know if is valid?
You need to call the validate()
method
Can I use my own validator?
Yes. It only needs to implement the interface IValidator.
Can I use my own converter?
Yes. It only needs to implement the interface IConverter.
About
Requirements
- Base Model works with PHP 7 or above.
Running Tests
You can run the tests executing the following command. Before you can run these, be sure to run composer install
.
Submitting bugs and feature requests
Bugs and feature request are tracked on GitHub
License
Base Model is licensed under the MIT License - see the LICENSE
file for details