Coleção de objetos de valores para implementação em sistemas.
npm install @devix-tecnologia/value-objectsRobust 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.
``bash`
npm i @devix-tecnologia/value-objects
`typescript`
import { ClassName } from '@devix-tecnologia/value-objects'
- Phone: Manipulates and validates phone numbers, supporting Brazilian DDD and country codes.
- CPF/CNPJ: Validates and formats CPF and CNPJ documents.
- Base64Image: Manages and validates base64-encoded images, with automatic format detection.
- Vehicle Plate: Validates and formats Brazilian vehicle plates, supporting both old (ABC1234) and Mercosul (ABC1D23) formats.
`typescript
import { Phone, CpfCnpj, Base64Image, PlacaVeiculo } 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.
// Vehicle Plate
const plate = new PlacaVeiculo('ABC1234')
console.log(plate.isValid()) // true
console.log(plate.formatted) // ABC-1234
console.log(plate.format) // ANTIGA
`
See the CONTRIBUTING.md file for more details.
---
> 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.