isSchemaType()
isSchemaType<
T>(schema,type):schema is SchemaOfType<T> & Schema<any> & { type: SchemaType }
Type guard to check if a schema matches a specific schema type.
Type Parametersβ
T: T extends SchemaTypeβ
Parametersβ
schema: GenericSchemaβ
The schema to check
type: Tβ
The schema type to check against
Returns: schema is SchemaOfType<T> & Schema<any> & { type: SchemaType }β
True if the schema matches the specified type
Sinceβ
2.0.0
Exampleβ
const schema: GenericSchema = string();
if (isSchemaType(schema, "string")) {
// schema is narrowed to StringSchema (base type, without constraint methods)
console.log(schema.type); // "string"
}