Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. export default DS.Model.extend({
  2. firstName: DS.attr(),
  3. lastName: DS.attr(),
  4. username: DS.attr(),
  5. email: DS.attr(),
  6. password: DS.attr(),
  7. confirmPassword: DS.attr()
  8.  
  9. import Ember from 'ember';
  10. import zxcvbn from 'npm:zxcvbn';
  11.  
  12. const {
  13. Component, String: { w }, isEmpty, set
  14. } = Ember;
  15. saved: false,
  16. classNames: ['container', 'form'], //creates the class
  17.  
  18. rules: {
  19. sharedValidations: {
  20. required: w('email firstName lastName userName confirmPassword')
  21. //this is ember shorthand to require these fields... see the const to
  22. understand the 'w' better
  23. },
  24. email: 'email',
  25. password: {
  26. required: true,
  27. between: [4,16],
  28. password(value) {
  29. if(isEmpty(value)) return "can't be blank";
  30. const { score } = zxcvbn(value);
  31. if (score < 3) return 'too weak';
  32. }
  33.  
  34. },
  35. actions: {
  36. submit() {
  37. set(this, 'saved', true);
  38.  
  39. }
  40. }
  41.  
  42. });
  43.  
  44. import Ember from 'ember';
  45.  
  46. export default Ember.Route.extend({
  47. model() {
  48. return this.get('store').createRecord('signup');
  49. }
  50. });
  51.  
  52. import DS from 'ember-data';
  53.  
  54. export default DS.JSONAPIAdapter.extend({
  55. namespace: 'api',
  56.  
  57. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement