// This file was autogenerated. Please do not change.
// All changes will be overwrited on commit.
export interface ILogin {
    password?: string;
    username?: string;
}

export default class Login {
    readonly _password: string | undefined;

    /** */
    get password(): string | undefined {
        return this._password;
    }

    readonly _username: string | undefined;

    /** */
    get username(): string | undefined {
        return this._username;
    }

    constructor(props: ILogin) {
        if (typeof props.password === 'string') {
            this._password = props.password.trim();
        }
        if (typeof props.username === 'string') {
            this._username = props.username.trim();
        }
    }

    serialize(): ILogin {
        const data: ILogin = {
        };
        if (typeof this._password !== 'undefined') {
            data.password = this._password;
        }
        if (typeof this._username !== 'undefined') {
            data.username = this._username;
        }
        return data;
    }

    validate(): string[] {
        const validate = {
            username: !this._username ? true : typeof this._username === 'string' && !this._username ? true : this._username,
            password: !this._password ? true : typeof this._password === 'string' && !this._password ? true : this._password,
        };
        const isError: string[] = [];
        Object.keys(validate).forEach((key) => {
            if (!(validate as any)[key]) {
                isError.push(key);
            }
        });
        return isError;
    }

    update(props: Partial<ILogin>): Login {
        return new Login({ ...this.serialize(), ...props });
    }
}
