Skip to content

YesNoTag

Paulo Gomes da Cruz Junior edited this page Apr 13, 2026 · 1 revision

YesNoTag

YesNoTag normalizes loosely typed values into a simple Yes or No label. It is intended for display-only contexts such as tables, summaries, and read-only details where source data may arrive as booleans, numbers, strings, or nullable values.

Props

Name Type Required Description
value boolean | string | number | null | undefined Yes Raw value to normalize into Yes or No.

Behavior

The component applies these normalization rules:

Boolean values

  • true => Yes
  • false => No

Number values

  • values greater than 0 => Yes
  • 0 and negative numbers => No

String values

Strings are trimmed and compared case-insensitively against this truthy set:

  • true
  • t
  • y
  • yes

Only those values map to Yes. All other strings map to No.

Examples:

  • "TRUE", "True", " true ", "YES" => Yes
  • "false", "no", "n", "f", "", "random" => No

Null and undefined

  • null => No
  • undefined => No

Usage

import YesNoTag from "@/components/core/Tags/YesNoTag";

<YesNoTag value={true} />;
<YesNoTag value={1} />;
<YesNoTag value="yes" />;
<YesNoTag value="no" />;
<YesNoTag value={null} />;

Rendering Notes

  • The component renders a plain <span> containing either Yes or No.
  • It does not apply custom styling, tag semantics, or interactivity.

Testing Notes

Unit tests cover all supported input categories:

  • booleans
  • numbers (positive, zero, negative)
  • truthy and non-truthy strings (including case and whitespace handling)
  • null and undefined

Waste Plus Wiki

Home

Architecture

Codes

Decisions

Knowledge Base

Development

Changes

Clone this wiki locally