MCPcopy
hub / github.com/massCodeIO/massCode / sanitizeMathSettings

Function sanitizeMathSettings

src/main/store/module/preferences.ts:197–214  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

195}
196
197function sanitizeMathSettings(value: unknown): MathSettings {
198 const source = asRecord(value)
199
200 const dateFormat = readString(source, 'dateFormat', MATH_DEFAULTS.dateFormat)
201 const validDateFormats = ['numeric', 'short', 'long']
202
203 return {
204 locale: readString(source, 'locale', MATH_DEFAULTS.locale),
205 decimalPlaces: readNumber(
206 source,
207 'decimalPlaces',
208 MATH_DEFAULTS.decimalPlaces,
209 ),
210 dateFormat: validDateFormats.includes(dateFormat)
211 ? (dateFormat as MathSettings['dateFormat'])
212 : MATH_DEFAULTS.dateFormat,
213 }
214}
215
216function sanitizeHttpSettings(value: unknown): HttpSettings {
217 const source = asRecord(value)

Callers 1

sanitizePreferencesFunction · 0.85

Calls 3

asRecordFunction · 0.90
readStringFunction · 0.90
readNumberFunction · 0.90

Tested by

no test coverage detected