Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow every character exept "[" and "]" for keys #20

Closed
wants to merge 1 commit into from

Conversation

nuxodin
Copy link

@nuxodin nuxodin commented Apr 3, 2014

No description provided.

@macek
Copy link
Owner

macek commented Apr 10, 2014

@nuxodin the FormSerializer.patterns are meant to be overridden if you need custom behavior in your application. Do not send a pull request for this kind of edit.

There's a couple examples in the API Documentation.

Hyphen example

$.extend(FormSerializer.patterns, {
  validate: /^[a-z][a-z0-9_-]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,
  key:      /[a-z0-9_-]+|(?=\[\])/gi,
  named:    /^[a-z0-9_-]+$/i
});

Dot-notation example

$.extend(FormSerializer.patterns, {
  validate: /^[a-z][a-z0-9_]*(?:\.[a-z0-9_]+)*(?:\[\])?$/i
});

For your application, it looks like you'll want to do this

$.extend(FormSerializer.patterns, {
  validate: /^[^\[\]]+(?:\[(?:\d*|[^\[\]]+)\])*$/i,
  key:      /[^\[\]]+|(?=\[\])/gi,
  named:    /^[^\[\]]+$/i
});

@macek macek closed this Apr 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants