New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add includeFormatSymbols for cnpj & cpf in brazil extensions #269
Add includeFormatSymbols for cnpj & cpf in brazil extensions #269
Conversation
…e to long or ulong is up to the developer.
Hi Arthur, Thank you for the Pull Request. I refactored the code to include an For example, The reasoning to keep it as a string is mostly because as a In the initial PR, This means however if you want to consume Bogus v28.4.2 is now available with these changes: void Main()
{
var c = new Company();
var cnpjList = Enumerable.Range(1,10)
.Select(_ => c.CnpjNumeric())
.ToArray();
cnpjList.Dump();
}
public static class MyCustomExtensionsForBogus
{
public static ulong CnpjNumeric(this Company c){
return ulong.Parse(c.Cnpj(includeFormatSymbols: false));
}
} I hope that helps. Thanks, |
The only problem with this solution is the context, when a value is requested with formatting, it will be impossible to get the same value without formatting, and vice versa. In separate methods, the context would eventually return the same value, and the method would replace. |
Is Cpf the only one with Person context? Did context work in previous version? |
The CPF is for the Brazilian the same as the SSN is for the Americans, so the same person can not have more than one number, it is unique for each individual. Therefore it must be kept in context to prevent data from being randomized. The new version still works, but once I generate formatted data, I can no longer get it without formatting, since it is in context with the first value |
Hi Arthur,
Thank you for the rely. I think what I'm trying to find out is if the
current CPF for Person with no context is the same as the previous version.
Does the previous version of Bogus before this PR have the same behavior of
no context when called on Person?
Ie:
```csharp
Var p = new Person()
p.Cpf()
p.Cpf()
```
Is the behavior the same in previous version of Bogus? If I recall
correctly, previous version has no context either. If that's the case then
we'll need a separate PR or issue. I'll try to investigate more later when
I'm off work.
…On Tue, Dec 3, 2019, 4:42 AM Arthur Henrique ***@***.*** wrote:
Is Cpf the only one with Person context? Did context work in previous
version?
The CPF is for the Brazilian the same as the SSN is for the Americans, so
the same person can not have more than one number, it is unique for each
individual. Therefore it must be kept in context to prevent data from being
randomized. The new version still works, but once I generate formatted
data, I can no longer get it without formatting, since it is in context
with the first value
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#269?email_source=notifications&email_token=AADUXJRT2BXWIJFNWADV2Q3QWZH4LA5CNFSM4JTD3MEKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFZHUYA#issuecomment-561150560>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADUXJRS2QNZQOMD46NUGALQWZH4LANCNFSM4JTD3MEA>
.
|
Both the current and previous versions returned the same value by exiting the following code: var p = new Person ();
var isEquals = p.Cpf () == p.Cpf () // true; This is correct and there is no problem. but with the latest version, |
Ah, thank you @ArthNRick. I understand the issue now. We'll get that fixed. |
Often developers need this data (cpf and cnpj) to be numeric, unformatted, that's what this implementation does.