Skip to content

Commit

Permalink
Creación de README para instrucciones de uso. Workflow para ejecutar …
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
tony98ms committed Mar 24, 2024
1 parent a85b248 commit 25f318a
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 18 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Laravel Validate Test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
with:
php-version: '8.3'
- uses: actions/checkout@v3
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Execute tests (Unit and Feature tests) via PHPUnit
run: vendor/bin/phpunit
65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# laravel-validate-ec
[![Latest Stable Version](http://poser.pugx.org/tonystore/laravel-validate-ec/v)](https://packagist.org/packages/tonystore/laravel-validate-ec) [![Total Downloads](http://poser.pugx.org/tonystore/laravel-validate-ec/downloads)](https://packagist.org/packages/tonystore/laravel-validate-ec) [![Latest Unstable Version](http://poser.pugx.org/tonystore/laravel-validate-ec/v/unstable)](https://packagist.org/packages/tonystore/laravel-validate-ec) [![License](http://poser.pugx.org/tonystore/laravel-validate-ec/license)](https://packagist.org/packages/tonystore/laravel-validate-ec) [![PHP Version Require](http://poser.pugx.org/tonystore/laravel-validate-ec/require/php)](https://packagist.org/packages/tonystore/laravel-validate-ec)

Librería para validar la estructura de los diferentes tipos de documentos de identificación emitidos para ecuador.

Para realizar las validaciones, se usa la librería [tavo1987/ec-validador-cedula-ruc](https://github.com/tavo1987/ec-validador-cedula-ruc) desarrollada por  [tavo1987](https://github.com/tavo1987) para PHP


Se podrá validar los números de identificación de los siguientes tipos:
* Cédula

## Requerimientos

- [PHP >= ^7.4](http://php.net)
- [Laravel 5| 6 | 7 | 8 | 9 | 10 | 11](https://laravel.com)


## Instalación via composer

Ejecuta este comando en la consola
``` bash
composer require tonystore/laravel-validate-ec
```
## Publicar archivos de traducciones
Por defecto, la librería contiene su mensaje de traducción para es y en, usted puede sobreescribir este mensaje de la siguiente manera

```sh
php artisan vendor:publish --provider="Tonystore\LaravelValidateEc\LaravelValidateEcProvider" --tag="validate-lang-es" // Validación en español
php artisan vendor:publish --provider="Tonystore\LaravelValidateEc\LaravelValidateEcProvider" --tag="validate-lang-en" // Validación en ingles
```

## Casos de uso
### Ejemplo 1
Uso mediante las validaciones de laravel
```php
<?php

$validatedData = $request->validate([
'cedula' => ['required', 'document_ec:ci'],
]);

```

### Ejemplo 2
Uso mediante una Regla de validación
```php
<?php

use Tonystore\LaravelValidateEc\Rules\ValidDocumentEc;

$validatedData = $request->validate([
'cedula' => ['required', new ValidDocumentEc('ci')],
]);

```

## Autor

Esta librería fue desarrollada y es mantenido por [Anthony Medina](https://github.com/tony98ms)

Si deseas contribuir con este proyecto o encuentras algún error, puedes crear un issue o un pull request, para esto deberá pasar todos los tests

## Licencia

Licencia de tipo [MIT License](LICENSE).
34 changes: 21 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
"name": "tonystore/laravel-validate-ec",
"description": "Libreria para validar la estructura de los diferentes tipos de documentos de identificación emitidos para ecuador",
"type": "library",
"keywords": ["laravel", "ecuador", "validador", "cedula", "ruc"],
"keywords": [
"laravel",
"ecuador",
"validador",
"cedula",
"ruc"
],
"require": {
"php": "^7.4 || ^8.0",
"php": "^7.4|^8.0",
"tavo1987/ec-validador-cedula-ruc": "^1.0",
"illuminate/validation": "^9.0 || ^10.0 || ^11.0",
"illuminate/support": "^9.0 || ^10.0 || ^11.0"
"illuminate/support": "~5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"illuminate/validation": "~5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0"
},
"require-dev": {
"orchestra/testbench": "^8.0",
"phpunit/phpunit": "^9.0 || ^10.0 || ^11.0",
"nunomaduro/collision": "^7.8"
"phpunit/phpunit": "~5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0",
"nunomaduro/collision": "~5.0|^6.0|^7.0|^8.0"
},
"license": "MIT",
"autoload": {
Expand All @@ -25,12 +31,14 @@
"Tonystore\\LaravelValidateEc\\Tests\\": "tests/"
}
},
"authors": [{
"name": "Anthony Medina Sandoval",
"email": "[email protected]",
"homepage": "https://github.com/tony98ms",
"role": "Developer"
}],
"authors": [
{
"name": "Anthony Medina Sandoval",
"email": "[email protected]",
"homepage": "https://github.com/tony98ms",
"role": "Developer"
}
],
"extra": {
"laravel": {
"providers": [
Expand All @@ -39,4 +47,4 @@
}
},
"minimum-stability": "dev"
}
}
3 changes: 0 additions & 3 deletions src/Rules/ValidDocumentEc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ class ValidDocumentEc implements Rule
private array $types = [
'ci' => 'validarCedula',
];
private $messages = [
'ci' => 'Cédula',
];
public function __construct(
private string $parameter,
) {
Expand Down
2 changes: 0 additions & 2 deletions tests/ValidateDocumentCiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tonystore\LaravelValidateEc\Tests;

use Illuminate\Support\Facades\Lang;
use Tonystore\LaravelValidateEc\Rules\ValidDocumentEc;

class ValidateDocumentCiTest extends TestCase
Expand All @@ -27,7 +26,6 @@ public function test_validate_ci_fail()
]);
$this->assertFalse($validator->passes());
}
/** @test */
public function test_validate_ci_with_rule()
{
$rules = ['ci' => [new ValidDocumentEc('ci')]];
Expand Down

0 comments on commit 25f318a

Please sign in to comment.