-
Notifications
You must be signed in to change notification settings - Fork 41
Remove leading zeros in Decimal type. #716
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
e6713a9
200575d
d12bcc6
7052f71
fc459e9
fe53050
6f3310f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
**AVERTISSEMENT :** Ceci effacera **toutes** les données qui ont jamais été enregistrées pour ce schéma. Cette opération est irréversible ! | ||
**AVERTISSEMENT :** Ceci effacera **toutes** les données enregistrées pour ce schéma. Cette opération est irréversible ! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
**AVERTISSEMENT !** Supprimer un schéma supprime certes ce schéma mais aussi **toutes** les données qui lui étaient associées. Cette opération est irréversible ! | ||
**AVERTISSEMENT !** Supprimer un schéma supprime le schéma et **toutes** les données qui lui sont associées. Cette opération est irréversible ! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
====== Struct - Éditeur de schémas ====== | ||
|
||
Les schémas sont la base du greffon Struct. Un schéma définit un ensemble de valeurs structurées que l'on peut ensuite affecter à des pages. | ||
Les schémas sont la base du plugin Struct. Un schéma définit un ensemble de valeurs structurées que l'on peut ensuite affecter à des pages. | ||
|
||
Choisissez un schéma existant depuis la table des matières ou créez-en un nouveau. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,7 +99,7 @@ public function renderValue($value, \Doku_Renderer $R, $mode) | |
public function validate($rawvalue) | ||
{ | ||
$rawvalue = parent::validate($rawvalue); | ||
$rawvalue = str_replace(',', '.', $rawvalue); // we accept both | ||
$rawvalue = trim((float)str_replace(',', '.', $rawvalue), 0); // we accept both | ||
|
||
if ((string)$rawvalue != (string)(float) $rawvalue) { | ||
throw new ValidationException('Decimal needed'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am wondering. Shouldn't this already prevent the issue you're trying to fix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your comments. I updated the code. Let me know if you have any comments. |
||
|
@@ -113,7 +113,9 @@ public function validate($rawvalue) | |
throw new ValidationException('Decimal max', (float) $this->config['max']); | ||
} | ||
|
||
// remove leading zeros | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment seems to be in the wrong place |
||
return $rawvalue; | ||
|
||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If my value is
1000
this will reduce it to1
.I believe casting the value to float should already do what you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are right. I will change that.