chore: seal Design Vision v1 and monorepo scaffold
Archive the differentiated YuXinGu product docs, AI engineering system, design contract, and Go/Vue scaffold. Next execution prioritizes Cece-parity over early innovation (see .ai/product/STRATEGY.md). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "@yuxingu/utils",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
/** Clamp a number into [min, max]. */
|
||||
export function clamp(n: number, min: number, max: number): number {
|
||||
return Math.min(max, Math.max(min, n))
|
||||
}
|
||||
|
||||
/** Pad date part to 2 digits. */
|
||||
export function pad2(n: number): string {
|
||||
return String(n).padStart(2, '0')
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate calendar-ish birth inputs.
|
||||
* Side effect: none. Returns error message or null if ok.
|
||||
*/
|
||||
export function validateBirth(year: number, month: number, day: number): string | null {
|
||||
if (!Number.isFinite(year) || year < 1900 || year > 2100) return '年份无效'
|
||||
if (month < 1 || month > 12) return '月份无效'
|
||||
if (day < 1 || day > 31) return '日期无效'
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user