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

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

    /** */
    get name(): string | undefined {
        return this._name;
    }

    readonly _password: string | undefined;

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

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

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

    validate(): string[] {
        const validate = {
            name: !this._name ? true : typeof this._name === 'string' && !this._name ? true : this._name,
            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 });
    }
}
