question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect value using angular form builder

See original GitHub issue

Example:

this.form = this.formBuilder.group({
      value: [4500, [Validators.required]],
});

Should return: R$ 45,00 It’s returning: R$ 4.500,00

My configs:

export const customCurrencyMaskConfig = {
  align: "left",
  allowNegative: true,
  allowZero: true,
  decimal: ",",
  precision: 2,
  prefix: "R$ ",
  suffix: "",
  thousands: ".",
  nullable: true,
  min: null,
  max: null,
  inputMode: CurrencyMaskInputMode.FINANCIAL,
};

Am I missing something? Thank you.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
devfelipereiscommented, Jul 29, 2020

Yeah, I did understand. The issue is that my entire database monetary values are integers. So in my database I do save 4500 for R$ 45,00.

I think that some projects also save integers for monetary values and maybe this lib should have an option to accept integers when using FINANCIAL type.

Thank you!

0reactions
rmalcombercommented, Sep 13, 2020

I too would like to see an integers option. As my data stored for monetary values are stored in whole pence (integers) - Alot of merchant and payment platforms work in integers to avoid rounding errors.

In my example

<input class="input input-price" currencyMask [(ngModel)]="value.price" [options]="{ prefix: '£ ', thousands: '.', decimal: '.', allowNegative: false }"" >

value.price = 650 displays = £650.00 Form Value = 650

type into input = 650 displays = £6.50 Form Value = 650

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 5 FormBuilder errors undefined when invalid input
Running the app: shows the formbuilder in the ts below initializes the input field correctly and if I add the [disabled] expression commented ......
Read more >
Validating form input - Angular
Every time the value of a form control changes, Angular runs validation and generates either a list of validation errors that results in...
Read more >
Valid and Invalid in Angular Forms | by Garen Stepanyan
In Angular one of most common ways to validate forms is to disable the submit button. It's a nice way (alongside with helpful...
Read more >
5 tips on using Angular FormControl | by Alain Chautard
valueChanges — Emits all value updates as soon as they happen · statusChanges — Emits all status updates (VALID or INVALID) as the...
Read more >
Show Validation Error Messages for Reactive Forms in ...
Show Validation Error Messages for Reactive Forms in Angular 9 · Show the Field is Required Using the Label · Show the Validation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found