Skip to content

[Code scan] Reject fractional values for integer fields #560

Description

@njzjz

This issue was found during a Codex global code scan of the repository.

Baseline commit: e3c5b38

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:

:rules="[
...(!jdata.optional ? rules.required : []),
...(['int', 'float'].includes(select_type) ? rules.number : []),
]"

} else if (["str", "int", "float"].includes(this.select_type)) {
if (!this.value) {
if (this.select_type == "str") return "";
else return 0;
}
if (!(this.select_type == "str")) {
return Number.parseFloat(this.value);
}

Relevant snippet:

...(['int', 'float'].includes(select_type) ? rules.number : []),
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions