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"
}