Category "enums"

In json schema, how to define an enum with description of each elements in the enum?

In json schema, I can simply define a code list using "enum" with a list of code that is available, for example: { "type": "object", "properties": { "gr

Automapper with EnumMapping throws on nullable Enums with unknown value

I have a nullable enum property on the source side and get this property with value 0 instead of NULL. But 0 is not a represented value in the enum so AutoMappe

Freezed class with enum property throws error upon trying to serialize

I have a freezed class that takes an enum in its constructor, but when trying to perform the jsonEncode method on this class, it fails with the following error:

how to deserialize xml arrayItems in enum if there are unrecognized elements

The goal is to deserialize xml-arrayitems into my specific enum. using System.Xml.Serialization; public enum Example { [XmlEnum(Name = "Ex1")] Ex1,

Convert a list of enums and store as 'varchar[]'

Trying to figure out how to store a list of enums in a single table column. I started with a String and it worked. I'll show only the relevant parts of the code

Is it possible to cast from one enum to another in PostgreSQL

I need to populate a new table in a second schema from an existing one, but having problems casting the "schema1.a.disclosure_level" column enum to the "schema2

FastAPI - dynamic inputs for different data types

I have to create a very generic endpoint for a user. The user may send JSON data or may upload a file to this endpoint. There are multiple options on how to han

Call async function in Enum

I want to refactor my code from sync to async. I use Python and FastAPI. I use the method which calls async function in Enumaration. For example: from enum impo

Entity Framework. How to map class with nested Enumeration class

I am using an Enumeration class like this public class SizeUnit : Enumeration { public static SizeUnit Inch = new SizeUnit(1, nameof(Inch)); public static

Boolean value remains false after the value of the static field involved changes

In my assignment I have to use an enum to make an EnumSet of elements that fit the criteria given. So, the code needs to be as flexible as possible and allow an

Add a mixin to python enum after it's created?

The Problem Suppose I have an enum defined: from enum import Enum, auto class Foo(Enum): DAVE_GROHL = auto() MR_T = auto() and I want to extend this cla

How to confirm an enumeration to Identifiable protocol in Swift?

I'm trying to make a list with the raw values of the cases from an enumeration with the new SwiftUI framework. However, I'm having a trouble with conforming the

Python Enum and Pydantic : accept enum member's composition

I have an enum : from enum import Enum class MyEnum(Enum): val1 = "val1" val2 = "val2" val3 = "val3" I would like to validate a pydantic field bas

Mongoose - array of enum strings

I have a Schema that has a property with the type of array of strings that are predefined. This is what I've tried to do: interests: { type: [String], e

how to override the toString method of an enum in dart

I'm just wondering if it's possible to override the toString method in dart this is what I have: enum Style{italic, bold, underline} Style.italic.toString() //

Perform checks on a nested enum

I have an enum which is defined as follows: enum MyEnum { X(u32), Y(Vec<MyEnum>), Z(Vec<MyEnum>), } As you can see, the enum is nested

How to make a Swift enum with associated values equatable

I have an enum of associated values which I would like to make equatable for testing purposes, but do not know how this pattern would work with an enum case wit

Flutter / Dart Convert Int to Enum

Is there a simple way to convert an integer value to enum? I want to retrieve an integer value from shared preference and convert it to an enum type. My enum i

Python Enum: How to get enum values with multiple attributes

I have defined two enums with attributes. When I want to access an enum element by specifying its attribute it works for enum A (one attribute) but not for enum

Why is Swift compiler complaining about circular reference when I comment out seemingly unrelated code?

Creating a brand new macOS Command Line Tool project in Xcode Version 13.3 (13E113), and replacing the contents of main.swift with the following code: import Fo