I have an enum like...
enum Analytics {
case event(name: String)
case other1
case other2
}
But I need to make sure that the name value is no longer than 40 characters.
Is there a way to have some sort of precondition on the value put into the enum? I'm not sure where this would/should exist? If this were a struct I could put a precondition or something in the init but how would I do that for an enum?
Thanks
In Swift, a restriction or refinement of a type can only be put in place using the type system.