Skip to content

Commit

Permalink
Merge pull request #1 from lfbn/improvement/add-changelog-better-readme
Browse files Browse the repository at this point in the history
Add Changelog. Improve Readme.
  • Loading branch information
lfbn committed Feb 13, 2018
2 parents dcb5261 + 0442cb7 commit e23f009
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 25 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [1.0.0] - 2018-02-14
### Added
- Added this CHANGELOG.
- Added more examples, about, and the LICENSE to the README file.
- Launch of first stable version. The API is defined.

## [0.0.1] - 2018-02-09
### Added
- Initial release.
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

Copyright (c) 2018 Luís Nóbrega

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66 changes: 42 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
# Base Model
# About Base Model

This is a Base Model that can be extended to define Models.
- [Features](#features)
- [Installation](#installation)
- [Examples](#examples)

# Features

* Validation of properties. All, except the isNotEmpty, doesn't validate the data if it is empty. Are available the following validators:
* isNotEmpty
* isNumeric
* isInteger
* isFloat
* isString
* isBoolean
* Model to array and JSON conversion, 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
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
* 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

```bash
composer require lfbn/base-model
```

# Examples
## Examples

## How to use it
### How to use it

You only need to extend the AbstractBaseModel and implement a public method getValidationRules.
Define your model extending the AbstractBaseModel, then implement a public method getValidationRules. This method should define the properties you want to validate.

This method should return an array with the properties and the respective validator method. Notice you can define your own method, and add it as a validator.
Here is an example:

```php
class User extends AbstractBaseModel
Expand Down Expand Up @@ -135,7 +139,7 @@ class User extends AbstractBaseModel

## How to know if is valid

You only need to call the ```validate()``` method
You need to call the ```validate()``` method

```php
$user = new User();
Expand All @@ -160,4 +164,18 @@ Yes. It only needs to implement the interface IConverter.
$user = new User();
$myConverter = new MyConverter();
$user->setConverter($myConverter);
```
```

## About

### Requirements

- Base Model works with PHP 7 or above.

### Submitting bugs and feature requests

Bugs and feature request are tracked on [GitHub](https://github.com/lfbn/base-model/issues)

### License

Base Model is licensed under the MIT License - see the `LICENSE` file for details
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lfbn/base-model",
"version": "0.0.1",
"version": "1.0.0",
"description": "Base Model",
"keywords": ["validation"],
"license": "MIT",
Expand Down

0 comments on commit e23f009

Please sign in to comment.