Defining new types with strict requirements

struct A <: Integer
    a::UInt8
    function A(a)
        a = mod(a, 250)
        return new(a)
    end
end
struct B <: Integer
    b::UInt32
    function B(b)
        (500<b<200_000) || error("No!")
        return new(b)
    end
end
struct D <: AbstractString
    d::UInt8
end
string(d::D) = "d$(D.d)" 

That’ll get you started.

3 Likes