DatatypeSchema
Validates a Roblox datatype by its typeof name, so a table that merely
carries the same fields is rejected — useful when the value arrived over a
remote, where anything can be sent.
Reached through the named constructors rather than built directly: Vet.color3 and Vet.udim2 both return one of these.
local Tint = v.color3()
local Size = v.udim2()
Tint:parse(Color3.new(1, 0, 0)) --> Color3(1, 0, 0)
Tint:parse({ R = 1, G = 0, B = 0 }) --> errors: expected Color3, got table
Size:parse(UDim2.fromScale(1, 1)) --> UDim2
Each datatype schema holds no state beyond the name it checks, so the constructors hand out one frozen shared instance rather than allocating.
Properties
typeName
This item is read only and cannot be modified. Read OnlyReflectionDatatypeSchema.typeName: stringThe typeof name this schema accepts, such as "Color3".
isOptional
This item is read only and cannot be modified. Read OnlyReflectionDatatypeSchema.isOptional: booleanAlways false. Datatypes carry no minimum or maximum.
access
This item is read only and cannot be modified. Read OnlyReflectionDatatypeSchema.access: "readwrite"Always "readwrite". Chain :readonly() or :writeonly() to change it.
Functions
safeParse
ParsingDatatypeSchema:safeParse(value: unknown) → Result<T>Validates value without throwing.
parse
ParsingDatatypeSchema:parse(value: unknown) → TValidates value and returns it, throwing on failure.
Errors
| Type | Description |
|---|---|
| "expected ..." | Thrown when `value` is a different type |
optional
WrapperWraps this schema so that nil is also accepted.
default
WrapperWraps this schema so that nil yields fallback instead of failing.
defaultWith
WrapperDatatypeSchema:defaultWith(produce: () → T--
Builds the value used when parsing nil
) → DefaultSchema<T>Like DatatypeSchema:default, but calls produce on every parse.
readonly
WrapperWraps this schema so that a field using it is typed read.
writeonly
WrapperWraps this schema so that a field using it is typed write.