@devix-tecnologia/value-objects
Version:
Coleção de objetos de valores para implementação em sistemas.
78 lines (58 loc) • 2.27 kB
Markdown
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.
- [Installation](
- [Requirements](
- [Import](
- [Available Value Objects](
- [Usage Examples](
- [To Do](
- [Contributing](
- [License](
```bash
npm i @devix-tecnologia/value-objects
```
- Node.js >= 18 (Node.js 20 or higher recommended)
- TypeScript >= 4.5 (optional, for typing)
```typescript
import { ClassName } from '@devix-tecnologia/value-objects'
```
- [Phone](./src/telefone/readme.md): Manipulates and validates phone numbers, supporting Brazilian DDD and country codes.
- [CPF/CNPJ](./src/cpf_cnpj/readme.md): Validates and formats CPF and CNPJ documents.
- [Base64Image](./src/imagem_base64/readme.md): Manages and validates base64-encoded images, with automatic format detection.
```typescript
import { Phone, CpfCnpj, Base64Image } from '@devix-tecnologia/value-objects'
// Phone
const tel = new Phone('+55 11 91234-5678')
console.log(tel.isValid()) // true
console.log(tel.format()) // +55 (11) 91234-5678
// CPF/CNPJ
const doc = new CpfCnpj('123.456.789-09')
console.log(doc.isValid()) // true
console.log(doc.format()) // 123.456.789-09
// Base64Image
const img = new Base64Image(base64String)
console.log(img.isValid()) // true
console.log(img.getFormat()) // 'png', 'jpeg', etc.
```
- Address
- Email
- Name (Individual)
- Money
- ZIP Code
Contributions are welcome! To contribute:
1. Fork this repository
2. Create a branch with your feature/fix
3. Submit a Pull Request
See the CONTRIBUTING.md file for more details.
This project is licensed under the MIT License. See the LICENSE file for more information.
---
> **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.