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

Primitive Field Type Fields.email(name) #82

Closed
CreativeWolf opened this issue Dec 31, 2015 · 13 comments
Closed

Primitive Field Type Fields.email(name) #82

CreativeWolf opened this issue Dec 31, 2015 · 13 comments
Milestone

Comments

@CreativeWolf
Copy link

It'd be good to have a Primitive Field Type Fields.email(name)

@paveltiunov
Copy link
Contributor

@CreativeWolf like text field with email pattern validation?

@CreativeWolf
Copy link
Author

Yes, that'd help :)

matteocng added a commit to matteocng/allcountjs that referenced this issue Jan 8, 2016
matteocng added a commit to matteocng/allcountjs that referenced this issue Jan 8, 2016
matteocng added a commit to matteocng/allcountjs that referenced this issue Jan 8, 2016
@CreativeWolf
Copy link
Author

@matteocng Firstly, Thank you for addressing this. Just a request, I understand Angular's default validation has issues with pattern recognition - angular/angular.js#5899 - Not sure if that's been changed now and I might be completely bringing up an unwarranted issue.
Just in case, if we are to use pattern, this seems to cover the bases:

return $compile('<input type="email" ng-model="emailValue" ng-pattern="/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/" class="form-control">')(scope);

References:
angular/angular.js#5899
http://www.w3resource.com/javascript/form/email-validation.php

Looking forward to your feedback.

Thanks!

@paveltiunov
Copy link
Contributor

@CreativeWolf nice point! Yep. As the issue requests we need some email validation. So we can start with client side validation as @CreativeWolf proposed. But I doubt solution with ng-pattern is user friendly in this context.

@paveltiunov paveltiunov reopened this Jan 8, 2016
@paveltiunov paveltiunov added this to the 1.23.4 milestone Jan 8, 2016
@matteocng
Copy link
Contributor

Thank you @CreativeWolf for bringing up the issue, I personally find this argument compelling as far as using the default, Chromium derived regex goes. Perhaps adding a layer of server side, non-pattern based validation could be a future evolution (e.g domain, mx, smtp, third party api).

@CreativeWolf
Copy link
Author

Fair point indeed. However, in an environment to have some user control, it becomes essential. Of course, as far as there is an option to use ng-pattern or Chromium derived regex or a custom pattern on the fly in a framework like AllcountJS will be highly useful.

@paveltiunov
Copy link
Contributor

Interesting. @matteocng have you checked that native browser email validation works both in a form and in the grid? It could be a solution.

@matteocng
Copy link
Contributor

@paveltiunov as far as i know a form is needed to get the native UI validation behaviour (native tooltip with natively generated message). @CreativeWolf I agree that letting users add their own custom logic/pattern on top of AllcountJS default validation would be a very useful feature, albeit more complex to implement well. What would you think of a regex('...', 'Message') method in the context of #4?

@paveltiunov
Copy link
Contributor

@matteocng just checked current behavior. It actually checks but in case email has wrong format it just doesn't save. It would be nice to notify user somehow that email has wrong format. Native tooltip doesn't appear for me.
How do you think?

@matteocng
Copy link
Contributor

@paveltiunov nice find, I've reproduced that behaviour. If you ran the app below, inserted 'a' in all six email, link and quantity fields and saved, the red error label 'Required' would just appear below the required() fields. Then, if you correctly filled in just the three required() fields, the save action would complete by saving 'null' in the DB for the three optional fields. As you correctly pointed out, it would be nice to 1) block the save action if invalid data was inserted in an optional field, showing an error label below it 2) change the 'Required' error label with a different message when the issue was a validation error; this change would affect both required and optional fields.

A.app({
  appName: "Validation behaviour",
  appIcon: "heart",
  menuItems: [
    {
      name: "Gifts",
      icon: "gift",
      entityTypeId: "Gift",
    }
  ],
  entities: function(Fields) {
    return {
      Gift: {
        title: 'Gifts',
        fields: {
          item: Fields.text("Item").required(),
          quantity: Fields.integer("Quantity"),
          quantity_required: Fields.integer("Quantity Required").required(),
          email: Fields.email("Email"),
          email_required: Fields.email("Email Required").required(),
          link: Fields.email("Link"),
          link_required: Fields.email("Link Required").required()
        }
      }
    }
  }
});

@paveltiunov
Copy link
Contributor

@matteocng Ah. I see. Nice workaround with required(). It might work for many situations. Do you think we need another issue for validation?

@matteocng
Copy link
Contributor

@paveltiunov Yes, moved to #91.

@paveltiunov
Copy link
Contributor

@matteocng Ok. Nice. Will close this one then.

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

3 participants