export class FileSha256 {
  private static readonly SHA256_PATTERN = /^[a-fA-F0-9]{64}$/

  private constructor(private readonly _value: string) {}

  static create(value: string): FileSha256 {
    if (!value || value.trim().length === 0) {
      throw new Error('SHA256 hash cannot be empty')
    }
    const trimmed = value.trim().toLowerCase()
    if (!FileSha256.SHA256_PATTERN.test(trimmed)) {
      throw new Error('Invalid SHA256 hash format')
    }
    return new FileSha256(trimmed)
  }

  get value(): string {
    return this._value
  }

  equals(other: FileSha256): boolean {
    return this._value === other._value
  }
}
