Require form control names to match a specific pattern

Rule ID:
name-pattern
Category:
Style
Standards:
-

Requires all names on form controls to match a given pattern.

Rule details

Examples of incorrect code for this rule:

<input name="foo-bar">
error: name "foo-bar" does not match the configured pattern "camelcase" (name-pattern) at inline:1:14:
> 1 | <input name="foo-bar">
    |              ^^^^^^^


1 error found.

Examples of correct code for this rule:

<input name="fooBar">

Array brackets are ignored by this rule:

<input name="fooBar[]">

Options

This rule takes an optional object:

{
  "pattern": "camelcase"
}

Pattern

Either one of the presets or a custom regular expression.

Read more about details and examples of predefined patterns.

Multiple patterns can be set as an array. If value matches either of the patterns it is considered valid.

Version history