import { HttpStep, IHttpStep } from '../../HttpStep.js'

export const IsNotEmptyAssertionKind = 'HttpAction#IsNotEmptyAssertion'

/**
 * An assertion that makes sure the input is empty (empty array, empty string, empty object - no properties)
 */
export interface IIsNotEmptyAssertion extends IHttpStep {
  kind: typeof IsNotEmptyAssertionKind
}

/**
 * An assertion that makes sure the input is empty (empty array, empty string, empty object - no properties)
 */
export class IsNotEmptyAssertion extends HttpStep {
  override kind = IsNotEmptyAssertionKind

  constructor(init?: IIsNotEmptyAssertion) {
    super()
    if (typeof init === 'object') {
      this.new(init)
    }
  }

  override new(init: IIsNotEmptyAssertion): void {
    super.new(init)
    this.kind = IsNotEmptyAssertionKind
  }

  checkValidity(): boolean {
    return true
  }

  override toJSON(): IIsNotEmptyAssertion {
    const result: IIsNotEmptyAssertion = {
      ...super.toJSON(),
      kind: IsNotEmptyAssertionKind,
    }
    return result
  }
}
