Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class UserRegisterDTO
- {
- public int Id { get; set; }
- [Required]
- public string Username { get; set; }
- [Required]
- [StringLength(12, MinimumLength = 8, ErrorMessage = "You must specify password between 8 and 12 chars.")]
- public string Password { get; set; }
- }
- register() {
- this.authService.register(this.model).subscribe(() => {
- this.alertify.success('Registration successful');
- }, error => {
- console.log(error);
- this.alertify.error(error);
- });
- }
- {Password: Array(1), Username: Array(1)}
- Password: ["You must specify password between 8 and 12 chars."]
- Username: ["The Username field is required."]
- __proto__:
- constructor: ƒ Object()
- hasOwnProperty: ƒ hasOwnProperty()
- isPrototypeOf: ƒ isPrototypeOf()
- propertyIsEnumerable: ƒ propertyIsEnumerable()
- toLocaleString: ƒ toLocaleString()
- toString: ƒ ()
- valueOf: ƒ valueOf()
- __defineGetter__: ƒ __defineGetter__()
- __defineSetter__: ƒ __defineSetter__()
- __lookupGetter__: ƒ __lookupGetter__()
- __lookupSetter__: ƒ __lookupSetter__()
- get __proto__: ƒ __proto__()
- set __proto__: ƒ __proto__()
- transformModelStateErrors(modelErrors: { [key:string]: string[] }) {
- const messages: string[] = [];
- for (let key of modelErrors) {
- for (let message of modelErrors[key]) {
- messages.push(`${key}: ${message}`);
- }
- }
- return messages;
- }
- register() {
- this.authService.register(this.model).subscribe(() => {
- this.alertify.success('Registration successful');
- }, error => {
- const messages = this.transformModelStateErrors(error);
- this.alertify.error(messages);
- });
- }
Add Comment
Please, Sign In to add comment