@devix-tecnologia/value-objects 2.1.6 → 2.2.1
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 +61 -25
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devix-tecnologia/value-objects",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
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
CHANGED
|
@@ -1,42 +1,78 @@
|
|
|
1
|
-
|
|
1
|
+
# @devix-tecnologia/value-objects
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
# Devix - Objetos de Valores
|
|
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.
|
|
6
4
|
|
|
7
|
-
|
|
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)
|
|
8
14
|
|
|
9
|
-
##
|
|
15
|
+
## Installation
|
|
10
16
|
|
|
11
|
-
```
|
|
17
|
+
```bash
|
|
12
18
|
npm i @devix-tecnologia/value-objects
|
|
13
19
|
```
|
|
14
20
|
|
|
15
|
-
##
|
|
21
|
+
## Requirements
|
|
22
|
+
- Node.js >= 18 (Node.js 20 or higher recommended)
|
|
23
|
+
- TypeScript >= 4.5 (optional, for typing)
|
|
24
|
+
|
|
25
|
+
## Import
|
|
16
26
|
|
|
17
|
-
```
|
|
18
|
-
import {
|
|
27
|
+
```typescript
|
|
28
|
+
import { ClassName } from '@devix-tecnologia/value-objects'
|
|
19
29
|
```
|
|
20
30
|
|
|
21
|
-
##
|
|
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'
|
|
22
41
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
26
46
|
|
|
27
|
-
|
|
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
|
|
28
51
|
|
|
29
|
-
|
|
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
|
|
30
60
|
- Email
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
-
|
|
61
|
+
- Name (Individual)
|
|
62
|
+
- Money
|
|
63
|
+
- ZIP Code
|
|
34
64
|
|
|
35
|
-
|
|
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
|
|
36
70
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
---
|
|
41
77
|
|
|
42
|
-
|
|
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.
|