SSML Builder Documentation - v1.0.1
    Preparing search index...

    Function isValidBreakStrength

    • Type guard to check if a string is a valid break strength value.

      Validates that the provided string is one of the allowed break strength values according to the SSML specification. This function acts as a TypeScript type guard, narrowing the type to BreakStrength when it returns true.

      Valid values:

      • x-weak: 250ms pause
      • weak: 500ms pause
      • medium: 750ms pause (default)
      • strong: 1000ms pause
      • x-strong: 1250ms pause

      Parameters

      • value: string

        The string value to validate

      Returns value is BreakStrength

      true if the value is a valid break strength, false otherwise

      // Valid strength
      if (isValidBreakStrength('medium')) {
      // TypeScript now knows this is a BreakStrength
      const strength: BreakStrength = 'medium';
      }

      // Invalid strength
      console.log(isValidBreakStrength('very-strong')); // false

      // Use in validation
      function setBreakStrength(value: string) {
      if (!isValidBreakStrength(value)) {
      throw new Error(`Invalid break strength: ${value}`);
      }
      // Safe to use as BreakStrength
      }