@devix-tecnologia/value-objects 2.1.4 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/readme.md +78 -0
- package/README.md +0 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devix-tecnologia/value-objects",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Coleção de objetos de valores para implementação em sistemas.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -67,5 +67,8 @@
|
|
|
67
67
|
"default": "./dist/cjs/index.js"
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=18.0.0"
|
|
70
73
|
}
|
|
71
74
|
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# @devix-tecnologia/value-objects
|
|
2
|
+
|
|
3
|
+
Robust library for manipulation and validation of value objects in JavaScript/TypeScript. Provides utility classes for common data such as phone numbers, documents, and base64 images, ensuring consistent validation and formatting.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [Installation](#installation)
|
|
7
|
+
- [Requirements](#requirements)
|
|
8
|
+
- [Import](#import)
|
|
9
|
+
- [Available Value Objects](#available-value-objects)
|
|
10
|
+
- [Usage Examples](#usage-examples)
|
|
11
|
+
- [To Do](#to-do)
|
|
12
|
+
- [Contributing](#contributing)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i @devix-tecnologia/value-objects
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Requirements
|
|
22
|
+
- Node.js >= 18 (Node.js 20 or higher recommended)
|
|
23
|
+
- TypeScript >= 4.5 (optional, for typing)
|
|
24
|
+
|
|
25
|
+
## Import
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
import { ClassName } from '@devix-tecnologia/value-objects'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Available Value Objects
|
|
32
|
+
|
|
33
|
+
- [Phone](./src/telefone/readme.md): Manipulates and validates phone numbers, supporting Brazilian DDD and country codes.
|
|
34
|
+
- [CPF/CNPJ](./src/cpf_cnpj/readme.md): Validates and formats CPF and CNPJ documents.
|
|
35
|
+
- [Base64Image](./src/imagem_base64/readme.md): Manages and validates base64-encoded images, with automatic format detection.
|
|
36
|
+
|
|
37
|
+
## Usage Examples
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { Phone, CpfCnpj, Base64Image } from '@devix-tecnologia/value-objects'
|
|
41
|
+
|
|
42
|
+
// Phone
|
|
43
|
+
const tel = new Phone('+55 11 91234-5678')
|
|
44
|
+
console.log(tel.isValid()) // true
|
|
45
|
+
console.log(tel.format()) // +55 (11) 91234-5678
|
|
46
|
+
|
|
47
|
+
// CPF/CNPJ
|
|
48
|
+
const doc = new CpfCnpj('123.456.789-09')
|
|
49
|
+
console.log(doc.isValid()) // true
|
|
50
|
+
console.log(doc.format()) // 123.456.789-09
|
|
51
|
+
|
|
52
|
+
// Base64Image
|
|
53
|
+
const img = new Base64Image(base64String)
|
|
54
|
+
console.log(img.isValid()) // true
|
|
55
|
+
console.log(img.getFormat()) // 'png', 'jpeg', etc.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## To Do
|
|
59
|
+
- Address
|
|
60
|
+
- Email
|
|
61
|
+
- Name (Individual)
|
|
62
|
+
- Money
|
|
63
|
+
- ZIP Code
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
Contributions are welcome! To contribute:
|
|
67
|
+
1. Fork this repository
|
|
68
|
+
2. Create a branch with your feature/fix
|
|
69
|
+
3. Submit a Pull Request
|
|
70
|
+
|
|
71
|
+
See the CONTRIBUTING.md file for more details.
|
|
72
|
+
|
|
73
|
+
## License
|
|
74
|
+
This project is licensed under the MIT License. See the LICENSE file for more information.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
> **Note:** The `Base64Image` component has been included in the list of value objects, with a link to specific documentation and a description aligned with the standard of the other components.
|
package/README.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
Aqui está o README.md atualizado da raiz do projeto, incluindo as informações do componente `ImagemBase64`:
|
|
2
|
-
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Devix - Objetos de Valores
|
|
6
|
-
|
|
7
|
-
Biblioteca para manipulação e validação de objetos de valor em JavaScript/TypeScript. Fornece classes utilitárias para lidar com dados comuns, como números de telefone, documentos e imagens em base64, garantindo validação e formatação consistentes.
|
|
8
|
-
|
|
9
|
-
## Instalação
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
npm i @devix-tecnologia/value-objects
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Importação
|
|
16
|
-
|
|
17
|
-
```js
|
|
18
|
-
import { NomeDaClasse } from '@devix-tecnologia/value-objects'
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
## Objetos de valor disponíveis
|
|
22
|
-
|
|
23
|
-
- <a href="./src/telefone/readme.md">Telefone</a> - Manipula e valida números de telefone, com suporte a DDD brasileiro e códigos de país.
|
|
24
|
-
- <a href="./src/cpf_cnpj/readme.md">CPF/CNPJ</a> - Valida e formata documentos CPF e CNPJ.
|
|
25
|
-
- <a href="./src/imagem_base64/readme.md">ImagemBase64</a> - Gerencia e valida imagens codificadas em base64, com detecção automática de formato.
|
|
26
|
-
|
|
27
|
-
## A fazer
|
|
28
|
-
|
|
29
|
-
- Endereço
|
|
30
|
-
- Email
|
|
31
|
-
- Nome (Pessoa Física)
|
|
32
|
-
- Dinheiro
|
|
33
|
-
- CEP
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
### Notas sobre a atualização:
|
|
38
|
-
1. **Adição do ImagemBase64**: Incluí o componente `ImagemBase64` na lista de objetos de valor, com um link para o README específico (`./src/imagem_base64/readme.md`) e uma breve descrição de sua funcionalidade.
|
|
39
|
-
2. **Estrutura mantida**: Preservei o formato original do README, apenas expandindo a seção de objetos de valor.
|
|
40
|
-
3. **Consistência**: Alinhei a descrição do `ImagemBase64` com o estilo das outras entradas (Telefone e CPF/CNPJ).
|
|
41
|
-
|
|
42
|
-
Se precisar de mais ajustes ou quiser que eu inclua algo específico, como exemplos adicionais ou uma seção de "Funções auxiliares" mais detalhada, é só pedir!
|