deepmodeling / deepmodeling/dpgui
[Code scan] Reject fractional values for integer fields
- Dominant language
- Vue
- Stars
- 9
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
This issue was found during a Codex global code scan of the repository.
Baseline commit: e3c5b38a99eb7ab778b5d8c68a5ed4ddf6cf91b3
Problem
Integer inputs use the same numeric validation and serialization path as floats. The validator accepts any value that is not `NaN`, and export uses `Number.parseFloat()` for both `int` and `float`.
Code references:
https://github.com/deepmodeling/dpgui/blob/e3c5b38a99eb7ab778b5d8c68a5ed4ddf6cf91b3/src/components/dargs/DargsItem.vue#L136-L139
https://github.com/deepmodeling/dpgui/blob/e3c5b38a99eb7ab778b5d8c68a5ed4ddf6cf91b3/src/components/dargs/DargsItem.vue#L342-L349
Relevant snippet:
```js
...(['int', 'float'].includes(select_type) ? rules.number : []),
```
```js
if (!(this.select_type == "str")) {
return Number.parseFloat(this.value);
}
```
Impact
A field declared as `int` can accept and export a fractional value such as `1.5`, producing invalid or semantically wrong input for downstream tools.
Suggested fix
Add a separate integer rule, for example based on `Number.isInteger(Number(value))`, and serialize `int` fields with an integer conversion after validation.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.