We've shipped a new validator for the Brazilian Inscrição Estadual (IE), enabling comprehensive validation across all states.
> impact
We're excited to announce the addition of a comprehensive validator for the Brazilian Inscrição Estadual (IE), or State Registration number. This new module, implemented in `brdoc.ie`, is specifically designed to handle the complex and varied validation algorithms required by each of Brazil's different states. The validator intelligently uses the provided state abbreviation to apply the correct checksum and formatting rules, ensuring accurate verification for any given IE number.
This feature was developed in response to a popular community request to expand the library's utility beyond CPF and CNPJ validation. The Inscrição Estadual is a fundamental identifier for companies that sell goods and some types of services, making it a crucial piece of data for e-commerce platforms, financial systems, and any application that manages Brazilian business entities. By adding IE support, `brdoc` becomes an even more indispensable tool for developers working within the Brazilian ecosystem.
The impact for developers is a significant simplification of data validation and compliance tasks. Instead of implementing and maintaining 27 different validation algorithms, you can now rely on a single `ie.is_valid(number, state)` function call. This reduces code complexity, minimizes potential for errors, and allows development teams to focus on core application features while trusting `brdoc` to handle the intricacies of Brazilian document validation.
> Try this now
try this
# To get started, import the new 'ie' module from brdoc.
from brdoc import ie
# Define a valid IE number for São Paulo (SP) and its state.
# The is_valid function requires both the number and the state's abbreviation.
sp_ie_valid = "110.042.490.114"
sp_state = "SP"
# Check if the São Paulo IE is valid. It should return True.
print(f"Is {sp_ie_valid} ({sp_state}) valid? {ie.is_valid(sp_ie_valid, sp_state)}")
# Now, let's try an invalid IE number for Rio de Janeiro (RJ).
rj_ie_invalid = "12.345.67-8"
rj_state = "RJ"
# The validator will correctly identify it as invalid, returning False.
print(f"Is {rj_ie_invalid} ({rj_state}) valid? {ie.is_valid(rj_ie_invalid, rj_state)}")