mirror of
https://github.com/frappe/books.git
synced 2026-08-24 02:24:17 -05:00
Merge pull request #1261 from frappe/fix-item-barcode
fix: validate item barcode to be exactly 12 digits
This commit is contained in:
@@ -107,6 +107,13 @@ export class Item extends Doc {
|
||||
};
|
||||
|
||||
validations: ValidationMap = {
|
||||
barcode: (value: DocValue) => {
|
||||
if (value && !(value as string).match(/^\d{12}$/)) {
|
||||
throw new ValidationError(
|
||||
this.fyo.t`Barcode must be exactly 12 digits.`
|
||||
);
|
||||
}
|
||||
},
|
||||
rate: (value: DocValue) => {
|
||||
if ((value as Money).isNegative()) {
|
||||
throw new ValidationError(this.fyo.t`Rate can't be negative.`);
|
||||
|
||||
Reference in New Issue
Block a user