import { SORT } from '../enums/sort';

export class Sort {
  field: string;
  dir: SORT;

  constructor(data: Partial<Sort>) {
    this.field = data?.field ?? '';
    this.dir = data?.dir ?? SORT.NONE;
  }

  isValid(): boolean {
    return this.field !== '' && this.dir !== SORT.NONE;
  }

  toString(): string {
    return `${this.field}:${this.dir}`;
  }
}
