Skip to content

decimal field with min or max, resolveInput triggers error #8597

@Thinkscape

Description

@Thinkscape

Steps

  1. Have a list with a decimal field
list({
  fields: {
    lineAmount: decimal({
      validation: { isRequired: false, min: "0.0" },
      defaultValue: "0",
      precision: 10,
      scale: 2,
    }),
});
  1. Have a list resolveInput that changes the value:
list({
  hooks: {
    resolveInput: ({ resolvedData }) {
      return {
        ...resolvedData,
        lineItem: 666
      };
   }
});
  1. Send a create or update against the list

Expected

Items gets created/updated successfully (with the lineItem: 666 value)

Actual

An error occured while running "validateInput".
  - ListName.lineAmount.hooks.validateInput: val.lessThan is not a function

Workarounds

  • Moving the logic to beforeOperation and mutating the resolvedData instance works around the problem.
  • Adding max to field config doesn't help.
  • Removing min max validation from field config works around it (but disables validation)
  • Returning number or string from resolveInput for the decimal field doesn't seem to change anything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions