/*
 * Tribufu API
 *
 * API to access Tribufu services.
 *
 * The version of the OpenAPI document: 1.2.6
 * Contact: contact@tribufu.com
 * Generated by: https://github.com/openapitools/openapi-generator.git
 */


using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using System.ComponentModel.DataAnnotations;
using OpenAPIDateConverter = Tribufu.Client.OpenAPIDateConverter;

namespace Tribufu.Model
{
    /// <summary>
    /// CreateUser
    /// </summary>
    [DataContract(Name = "CreateUser")]
    public partial class CreateUser : IValidatableObject
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateUser" /> class.
        /// </summary>
        [JsonConstructorAttribute]
        protected CreateUser() { }
        /// <summary>
        /// Initializes a new instance of the <see cref="CreateUser" /> class.
        /// </summary>
        /// <param name="uuid">uuid.</param>
        /// <param name="name">name (required).</param>
        /// <param name="displayName">displayName.</param>
        /// <param name="email">email.</param>
        /// <param name="password">password.</param>
        /// <param name="language">language.</param>
        /// <param name="timezone">timezone.</param>
        /// <param name="currency">currency.</param>
        /// <param name="ipAddress">ipAddress.</param>
        public CreateUser(Guid? uuid = default(Guid?), string name = default(string), string displayName = default(string), string email = default(string), string password = default(string), string language = default(string), string timezone = default(string), string currency = default(string), string ipAddress = default(string))
        {
            // to ensure "name" is required (not null)
            if (name == null)
            {
                throw new ArgumentNullException("name is a required property for CreateUser and cannot be null");
            }
            this.Name = name;
            this.Uuid = uuid;
            this.DisplayName = displayName;
            this.Email = email;
            this.Password = password;
            this.Language = language;
            this.Timezone = timezone;
            this.Currency = currency;
            this.IpAddress = ipAddress;
        }

        /// <summary>
        /// Gets or Sets Uuid
        /// </summary>
        [DataMember(Name = "uuid", EmitDefaultValue = true)]
        public Guid? Uuid { get; set; }

        /// <summary>
        /// Gets or Sets Name
        /// </summary>
        [DataMember(Name = "name", IsRequired = true, EmitDefaultValue = true)]
        public string Name { get; set; }

        /// <summary>
        /// Gets or Sets DisplayName
        /// </summary>
        [DataMember(Name = "display_name", EmitDefaultValue = true)]
        public string DisplayName { get; set; }

        /// <summary>
        /// Gets or Sets Email
        /// </summary>
        [DataMember(Name = "email", EmitDefaultValue = true)]
        public string Email { get; set; }

        /// <summary>
        /// Gets or Sets Password
        /// </summary>
        [DataMember(Name = "password", EmitDefaultValue = true)]
        public string Password { get; set; }

        /// <summary>
        /// Gets or Sets Language
        /// </summary>
        [DataMember(Name = "language", EmitDefaultValue = true)]
        public string Language { get; set; }

        /// <summary>
        /// Gets or Sets Timezone
        /// </summary>
        [DataMember(Name = "timezone", EmitDefaultValue = true)]
        public string Timezone { get; set; }

        /// <summary>
        /// Gets or Sets Currency
        /// </summary>
        [DataMember(Name = "currency", EmitDefaultValue = true)]
        public string Currency { get; set; }

        /// <summary>
        /// Gets or Sets IpAddress
        /// </summary>
        [DataMember(Name = "ip_address", EmitDefaultValue = true)]
        public string IpAddress { get; set; }

        /// <summary>
        /// Returns the string presentation of the object
        /// </summary>
        /// <returns>String presentation of the object</returns>
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("class CreateUser {\n");
            sb.Append("  Uuid: ").Append(Uuid).Append("\n");
            sb.Append("  Name: ").Append(Name).Append("\n");
            sb.Append("  DisplayName: ").Append(DisplayName).Append("\n");
            sb.Append("  Email: ").Append(Email).Append("\n");
            sb.Append("  Password: ").Append(Password).Append("\n");
            sb.Append("  Language: ").Append(Language).Append("\n");
            sb.Append("  Timezone: ").Append(Timezone).Append("\n");
            sb.Append("  Currency: ").Append(Currency).Append("\n");
            sb.Append("  IpAddress: ").Append(IpAddress).Append("\n");
            sb.Append("}\n");
            return sb.ToString();
        }

        /// <summary>
        /// Returns the JSON string presentation of the object
        /// </summary>
        /// <returns>JSON string presentation of the object</returns>
        public virtual string ToJson()
        {
            return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
        }

        /// <summary>
        /// To validate all properties of the instance
        /// </summary>
        /// <param name="validationContext">Validation context</param>
        /// <returns>Validation Result</returns>
        IEnumerable<ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
        {
            // Name (string) maxLength
            if (this.Name != null && this.Name.Length > 45)
            {
                yield return new ValidationResult("Invalid value for Name, length must be less than 45.", new [] { "Name" });
            }

            // Name (string) minLength
            if (this.Name != null && this.Name.Length < 1)
            {
                yield return new ValidationResult("Invalid value for Name, length must be greater than 1.", new [] { "Name" });
            }

            if (this.Name != null) {
                // Name (string) pattern
                Regex regexName = new Regex(@"^[a-zA-Z0-9-_]*$", RegexOptions.CultureInvariant);
                if (!regexName.Match(this.Name).Success)
                {
                    yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Name, must match a pattern of " + regexName, new [] { "Name" });
                }
            }

            // DisplayName (string) maxLength
            if (this.DisplayName != null && this.DisplayName.Length > 45)
            {
                yield return new ValidationResult("Invalid value for DisplayName, length must be less than 45.", new [] { "DisplayName" });
            }

            if (this.DisplayName != null) {
                // DisplayName (string) pattern
                Regex regexDisplayName = new Regex(@"^[a-zA-Z0-9-_ ]*$", RegexOptions.CultureInvariant);
                if (!regexDisplayName.Match(this.DisplayName).Success)
                {
                    yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for DisplayName, must match a pattern of " + regexDisplayName, new [] { "DisplayName" });
                }
            }

            // Email (string) maxLength
            if (this.Email != null && this.Email.Length > 255)
            {
                yield return new ValidationResult("Invalid value for Email, length must be less than 255.", new [] { "Email" });
            }

            // Language (string) maxLength
            if (this.Language != null && this.Language.Length > 5)
            {
                yield return new ValidationResult("Invalid value for Language, length must be less than 5.", new [] { "Language" });
            }

            // Currency (string) maxLength
            if (this.Currency != null && this.Currency.Length > 3)
            {
                yield return new ValidationResult("Invalid value for Currency, length must be less than 3.", new [] { "Currency" });
            }

            // IpAddress (string) maxLength
            if (this.IpAddress != null && this.IpAddress.Length > 255)
            {
                yield return new ValidationResult("Invalid value for IpAddress, length must be less than 255.", new [] { "IpAddress" });
            }

            yield break;
        }
    }

}
