MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / processCasing

Function processCasing

packages/orm/src/client/functions.ts:144–159  ·  view source on GitHub ↗
(casing: Expression<any>, result: string, model: string)

Source from the content-addressed store, hash-verified

142};
143
144function processCasing(casing: Expression<any>, result: string, model: string) {
145 const opNode = casing.toOperationNode();
146 invariant(ValueNode.is(opNode) && typeof opNode.value === 'string', '"casting" parameter must be a string value');
147 result = match(opNode.value)
148 .with('original', () => model)
149 .with('upper', () => result.toUpperCase())
150 .with('lower', () => result.toLowerCase())
151 .with('capitalize', () => upperCaseFirst(result))
152 .with('uncapitalize', () => lowerCaseFirst(result))
153 .otherwise(() => {
154 throw new Error(
155 `Invalid casing value: ${opNode.value}. Must be "original", "upper", "lower", "capitalize", or "uncapitalize".`,
156 );
157 });
158 return result;
159}
160
161function readBoolean(expr: Expression<any> | undefined, defaultValue: boolean) {
162 if (expr === undefined) {

Callers 2

currentModelFunction · 0.85
currentOperationFunction · 0.85

Calls 3

invariantFunction · 0.90
upperCaseFirstFunction · 0.90
lowerCaseFirstFunction · 0.90

Tested by

no test coverage detected