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

Function normalizeFloatDefault

packages/cli/src/actions/pull/utils.ts:203–211  ·  view source on GitHub ↗
(val: string)

Source from the content-addressed store, hash-verified

201 * - Decimal strings are preserved as-is
202 */
203export function normalizeFloatDefault(val: string): (ab: ExpressionBuilder) => AstFactory<Expression> {
204 if (/^-?\d+$/.test(val)) {
205 return (ab) => ab.NumberLiteral.setValue(val + '.0');
206 }
207 if (/^-?\d+\.\d+$/.test(val)) {
208 return (ab) => ab.NumberLiteral.setValue(val);
209 }
210 return (ab) => ab.NumberLiteral.setValue(val);
211}
212
213/**
214 * Normalize a default value string for a Decimal field.

Callers 3

getDefaultValueFunction · 0.90
getDefaultValueFunction · 0.90
getDefaultValueFunction · 0.90

Calls 1

setValueMethod · 0.45

Tested by

no test coverage detected