{"record":{"id":"83878652b33845d8","repo":"qax-os/excelize","slug":"custom-number-format-can-not-be-empty","errorCode":null,"errorMessage":"custom number format can not be empty","messagePattern":"custom number format can not be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"errors.go","lineNumber":46,"sourceCode":"\t// characters length that exceeds the limit.\n\tErrCellCharsLength = fmt.Errorf(\"cell value must be 0-%d characters\", TotalCellChars)\n\t// ErrCellStyles defined the error message on cell styles exceeds the limit.\n\tErrCellStyles = fmt.Errorf(\"the cell styles exceeds the %d limit\", MaxCellStyles)\n\t// ErrChartTitle defined the error message on both formula and rich text for\n\t// chart title.\n\tErrChartTitle = errors.New(\"cannot set both 'Formula' and 'Paragraph' for chart title\")\n\t// ErrColumnNumber defined the error message on receive an invalid column\n\t// number.\n\tErrColumnNumber = fmt.Errorf(\"the column number must be greater than or equal to %d and less than or equal to %d\", MinColumns, MaxColumns)\n\t// ErrColumnWidth defined the error message on receive an invalid column\n\t// width.\n\tErrColumnWidth = fmt.Errorf(\"the width of the column must be less than or equal to %d characters\", MaxColumnWidth)\n\t// ErrCoordinates defined the error message on invalid coordinates tuples\n\t// length.\n\tErrCoordinates = errors.New(\"coordinates length must be 4\")\n\t// ErrCustomNumFmt defined the error message on receive the empty custom\n\t// number format.\n\tErrCustomNumFmt = errors.New(\"custom number format can not be empty\")\n\t// ErrDataValidationFormulaLength defined the error message for receiving a\n\t// data validation formula length that exceeds the limit.\n\tErrDataValidationFormulaLength = fmt.Errorf(\"data validation must be 0-%d characters\", MaxFieldLength)\n\t// ErrDataValidationRange defined the error message on set decimal range\n\t// exceeds limit.\n\tErrDataValidationRange = errors.New(\"data validation range exceeds limit\")\n\t// ErrDefinedNameDuplicate defined the error message on the same name\n\t// already exists on the scope.\n\tErrDefinedNameDuplicate = errors.New(\"the same name already exists on the scope\")\n\t// ErrDefinedNameScope defined the error message on not found defined name\n\t// in the given scope.\n\tErrDefinedNameScope = errors.New(\"no defined name on the scope\")\n\t// ErrExistsSheet defined the error message on given sheet already exists.\n\tErrExistsSheet = errors.New(\"the same name sheet already exists\")\n\t// ErrExistsTableName defined the error message on given table already\n\t// exists.\n\tErrExistsTableName = errors.New(\"the same name table already exists\")\n\t// ErrFillType defined the error message on receive an invalid fill type.","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/qax-os/excelize/blob/f2483381fbfbe432a6baa98d48a1c277183f3285/errors.go#L28-L64","documentation":"ErrCustomNumFmt is returned when a Style specifies CustomNumFmt as a non-nil pointer to an empty string. The library treats a present-but-empty custom number format as invalid, since an empty format code cannot be applied to cells. It is raised in parseFormatStyleSet (styles.go) and surfaced via NewStyle/NewConditionalStyle.","triggerScenarios":"Calling f.NewConditionalStyle(&Style{CustomNumFmt: &empty}) or f.NewStyle with CustomNumFmt pointing to \"\" — the pointer is non-nil so the field is 'set', but the string is empty.","commonSituations":"Declaring var fmt string (zero value \"\") and taking its address; template/config values that failed to populate leaving an empty string; copying a Style struct where the original had a valid format that got cleared.","solutions":["Set the CustomNumFmt string to a valid format code (e.g. \"0.00\", \"yyyy-mm-dd\") before calling NewStyle/NewConditionalStyle","If no custom format is needed, leave CustomNumFmt nil instead of pointing at an empty string","Validate the format string non-empty before constructing the Style","Check where the value is sourced (config, template) to fix the upstream empty value"],"exampleFix":"// before\nvar exp string\n_, err := f.NewConditionalStyle(&Style{CustomNumFmt: &exp}) // ErrCustomNumFmt\n// after\nnumFmt := \"0.00\"\n_, err := f.NewConditionalStyle(&Style{CustomNumFmt: &numFmt})","handlingStrategy":"validation","validationCode":"func validCustomNumFmt(s *string) bool { return s == nil || *s != \"\" }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Leave CustomNumFmt nil when unused","Never take the address of a zero-value string variable","Validate format strings at config-load time","Source format codes from constants, not ad-hoc empty vars"],"tags":["styles","number-format","empty-value"],"backgroundTag":"empty-required-field","analyzedSha":"f2483381fbfbe432a6baa98d48a1c277183f3285","analyzedAt":"2026-09-02T01:26:19.299Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}