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

[Validation] Legacy Settings Detection Incorrectly Duck-Types #2629

Closed
smangelsdorf opened this issue Jul 14, 2015 · 5 comments
Closed

[Validation] Legacy Settings Detection Incorrectly Duck-Types #2629

smangelsdorf opened this issue Jul 14, 2015 · 5 comments
Milestone

Comments

@smangelsdorf
Copy link

JSFiddle: http://jsfiddle.net/jev4qec3/1/

If it's relevant, I'm using Chrome.

I hit this problem while porting an application forward from Semantic UI 1.x. After refactoring my validations to use the new form validation API, one form was still reporting the following error:

Form: Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically.

After that, attempting to submit the form gives the following error:

Uncaught Error: Syntax error, unrecognized expression: #[object Object] 

The JSFiddle linked above has validations configured with an added underscore to work around the issue. Removing the underscore triggers the error.

@jlukic jlukic changed the title Field named identifier causes error with form validations [Validation] Type Check Against Validation Identifier Jul 14, 2015
@jlukic
Copy link
Member

jlukic commented Jul 14, 2015

It looks like an object is being passed in as a validation identifier, I'm unsure the exact issue without a test case, but it seems clear to me that get field should do some basic type checking.

@jlukic jlukic added this to the 2.0.4 milestone Jul 14, 2015
@jlukic
Copy link
Member

jlukic commented Jul 14, 2015

I've gone ahead and added type validation, if you have a test case that produces the error when passing in a normal string identifier let me know, and I'll examine separately.

@jlukic jlukic closed this as completed Jul 14, 2015
@smangelsdorf
Copy link
Author

@jlukic: I'm not sure if I'm understanding you correctly, but I may not have explained myself clearly.

I followed this example from the documentation:

$('.ui.form')
  .form({
    fields: {
      name: {
        identifier  : 'name',
        rules: [
          {
            type   : 'empty',
            prompt : 'Please enter your name'
          }
        ]
      },
      skills: {
        identifier : 'skills',
        rules: [
          type   : 'minCount[2]',
          prompt : 'Please select at least two skills'
        ]
      },
      // ....
    }
  })
;

The specific issue is when instead of skills, the second field is called identifier. In that case, Semantic UI appears to detect the top level fields object as being an old style validation because it has an identifier property. (When in fact, the identifier property is just a validation on a field called identifier)

And then, later in the code, attempting to treat the validations for the field identifier as an identifier causes the error.

@jlukic
Copy link
Member

jlukic commented Jul 15, 2015

Sorry I think the first post when I visited didn't have a test case (or i missed it). I'll take a look at a fix.

@jlukic jlukic reopened this Jul 15, 2015
@jlukic jlukic changed the title [Validation] Type Check Against Validation Identifier [Validation] Legacy Settings Detection Incorrectly Duck-Types Jul 16, 2015
@jlukic
Copy link
Member

jlukic commented Jul 16, 2015

Sorry about the confusion, fixed in patch.

@jlukic jlukic closed this as completed Jul 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants