• @Enum decorator

    Validates the final content of the property belong to a typescript Enum object passed as a parameter.

    Type Parameters

    • This
    • Value

    Parameters

    Returns DecoratorType<This, Value | Value[]>

    You can validate a property to an enum based on a number.

    enum ReadWrite {
    ReadOnly = 1,
    ReadWrite = 2,
    }

    class Protocol {
    @Enum(ReadWrite)
    @Relation(PrimitiveSymbol.u8)
    type: ReadWrite
    }

    Or based on a string.

    enum ChunkType {
    IEND = 'IEND',
    IDAT = 'IDAT',
    }

    class Protocol {
    @Enum(ChunkType)
    @Count(4)
    @Relation(PrimitiveSymbol.char)
    type: ReadWrite
    }