Guest User

Untitled

a guest
Nov 7th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. public class UserRegisterDTO
  2. {
  3. public int Id { get; set; }
  4. [Required]
  5. public string Username { get; set; }
  6. [Required]
  7. [StringLength(12, MinimumLength = 8, ErrorMessage = "You must specify password between 8 and 12 chars.")]
  8. public string Password { get; set; }
  9. }
  10.  
  11. register() {
  12. this.authService.register(this.model).subscribe(() => {
  13. this.alertify.success('Registration successful');
  14. }, error => {
  15. console.log(error);
  16. this.alertify.error(error);
  17. });
  18. }
  19.  
  20. {Password: Array(1), Username: Array(1)}
  21. Password: ["You must specify password between 8 and 12 chars."]
  22. Username: ["The Username field is required."]
  23. __proto__:
  24. constructor: ƒ Object()
  25. hasOwnProperty: ƒ hasOwnProperty()
  26. isPrototypeOf: ƒ isPrototypeOf()
  27. propertyIsEnumerable: ƒ propertyIsEnumerable()
  28. toLocaleString: ƒ toLocaleString()
  29. toString: ƒ ()
  30. valueOf: ƒ valueOf()
  31. __defineGetter__: ƒ __defineGetter__()
  32. __defineSetter__: ƒ __defineSetter__()
  33. __lookupGetter__: ƒ __lookupGetter__()
  34. __lookupSetter__: ƒ __lookupSetter__()
  35. get __proto__: ƒ __proto__()
  36. set __proto__: ƒ __proto__()
  37.  
  38. transformModelStateErrors(modelErrors: { [key:string]: string[] }) {
  39. const messages: string[] = [];
  40.  
  41. for (let key of modelErrors) {
  42. for (let message of modelErrors[key]) {
  43. messages.push(`${key}: ${message}`);
  44. }
  45. }
  46.  
  47. return messages;
  48. }
  49.  
  50. register() {
  51. this.authService.register(this.model).subscribe(() => {
  52. this.alertify.success('Registration successful');
  53. }, error => {
  54. const messages = this.transformModelStateErrors(error);
  55. this.alertify.error(messages);
  56. });
  57. }
Add Comment
Please, Sign In to add comment