Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1965 (closed enhancement: fixed)

Opened 11 years ago

Last modified 10 years ago

[PATCH] Improved Number validator, setting number of decimals

Reported by: ghorvath Owned by: anonymous
Priority: normal Milestone: 1.1.x bugfix
Component: TurboGears Version: 1.1 HEAD
Severity: normal Keywords: Validator, needs tests
Cc:

Description

If the validator instance has a dec_places attribute it is used for the number of decimals for the output of from_python. If None ist given the number of decimals is determined by the value like before.

>>> Number(dec_places=2).from_python(1.336)
u'1.34'
>>> Number().from_python(1.336)
u'1.336'

Attached a patched against 1.1 r5251

Attachments

improvednumbervalidator.diff Download (1.5 KB) - added by ghorvath 11 years ago.
Diff Improved number validator, setting dec places

Change History

Changed 11 years ago by ghorvath

Diff Improved number validator, setting dec places

comment:1 Changed 11 years ago by Chris Arndt

  • Keywords Validator, needs tests added; Validator removed

Can you provide some test that a) show that validator is used in practice and b) test that it works as it should ;)

I would also change the name dec_places to decimal_places. That makes it easier to grasp at once what it is for.

The tests could go into the turbogears.tests.test_validators.test_number_validador (sic!) function.

comment:2 Changed 10 years ago by faide

  • Milestone changed from 1.1 to 1.1 maintenance

comment:3 Changed 10 years ago by chrisz

Implemented in r6316.

comment:4 Changed 10 years ago by chrisz

  • Status changed from new to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.