Skip to content

addMethod function accepts an object for the "params" parameter of the custom validation function but doesn't process it as an object. #2516

Closed
@buddyackerman

Description

@buddyackerman

Your environment

  • Version of jquery-validate: 1.19.5
  • Browser name and version: Chrome 134

Current behavior

Create a new validation method using the addMethod function.

jQuery.validator.addMethod( 'requireSelection', requireSelectionValidator, $.validator.format('Please select a value from {params.fieldname} list') )

use it in a rule

rules: {
  SomeField: {
    requireSelection: {
      param: {
        fieldName: 'Some Field',
        list: data.availableCoils.map(x => x.ASSEMBLY_SN_1)
      }
    }
  },

Expected behavior

The {params.fieldname} replace token should be replaced by the params object's specified property.

Live demo

Here's a stackblitz example, just press the validate button

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions