Data Pipeline Case Studies
Input Normalization Case
A small normalization step can clean user input before later code stores or routes it.
Input Normalization Case
normalize.ts
type NormalizedUser = {
displayName: string;
slug: string;
};
function normalizeUser(rawName: string): NormalizedUser {
const trimmed: string = rawName.trim();
const displayName: string = trimmed.replace(/\s+/g, " ");
const slug: string = displayName.toLowerCase().replace(/\s+/g, "-");
return { displayName, slug };
}
const rawName: string = ;
const user: NormalizedUser = normalizeUser(rawName);
console.log(`name=${user.displayName};slug=${user.slug}`);
type NormalizedUser = {
displayName: string;
slug: string;
};
function normalizeUser(rawName: string): NormalizedUser {
const trimmed: string = rawName.trim();
const displayName: string = trimmed.replace(/\s+/g, " ");
const slug: string = displayName.toLowerCase().replace(/\s+/g, "-");
return { displayName, slug };
}
const rawName: string = ;
const user: NormalizedUser = normalizeUser(rawName);
console.log(`name=${user.displayName};slug=${user.slug}`);
input normalization
Normalize early so the rest of the pipeline sees a predictable typed record.