FEAT-5: Probeverpaarung page — free genotype entry, client-side breed(), Farbschlag cards + warnings
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
22
gerbil-manager-web/src/format/genotypeText.ts
Normal file
22
gerbil-manager-web/src/format/genotypeText.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/** Helpers for free-text genotype input (parse/validate/preview via GEN-1). */
|
||||
import { fromDisplayString, genotypeToFarbschlag } from '../genetics'
|
||||
|
||||
export function isValidGenotype(genotype: string): boolean {
|
||||
if (!genotype.trim()) return false
|
||||
try {
|
||||
fromDisplayString(genotype)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** Resolved Farbschlag for a genotype string, or null if empty/invalid. */
|
||||
export function previewFarbschlag(genotype: string): string | null {
|
||||
if (!genotype.trim()) return null
|
||||
try {
|
||||
return genotypeToFarbschlag(fromDisplayString(genotype))
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user