Function NO_DUPLICATE_ENUM_KEYS

  • Because a lot of the other constrain functions (such as NO_NUMBER_START_CHAR, NO_EMPTY_VALUE, etc) they might manipulate the enum keys by append, prepend, or manipulate it any other way. We then need to make sure that they don't clash with any existing enum keys, this is what this function handles. If so, prepend reserved_ to the enum key and recheck.

    Parameters

    • constrainedEnumModel: ConstrainedEnumModel

      the current constrained enum model, which contains already existing constrained enum keys

    • enumModel: EnumModel

      the raw enum model which is non-constrained to the output language.

    • enumKey: string

      one of the enum keys in enumModel which might have been manipulated.

    • namingFormatter: ((value) => string)

      the name formatter which are used to format the enum key.

        • (value): string
        • Parameters

          • value: string

          Returns string

    • enumKeyToCheck: string = enumKey

      the enum key to use for checking if it already exist, defaults to enumKey.

    • onNameChange: ((currentEnumKey) => string) = ...

      callback to change the name of the enum key that needs to be returned.

        • (currentEnumKey): string
        • Parameters

          • currentEnumKey: string

          Returns string

    • onNameChangeToCheck: ((currentEnumKey) => string) = onNameChange

      callback to change the enum key which is being checked as part of the existing models.

        • (currentEnumKey): string
        • Parameters

          • currentEnumKey: string

          Returns string

    Returns string

    the potential new enum key that does not clash with existing enum keys.

Generated using TypeDoc