Sha256: ec957922b46bb3b2cf9ae956bc9962b00a4265f786a6345a21272230fb3302cb
Contents?: true
Size: 747 Bytes
Versions: 9
Compression:
Stored size: 747 Bytes
Contents
import { filterRHSubscriptions } from './SubscriptionHelpers.js'; export const validateQuantity = (quantity, availableQuantity) => { let state; let message; const numberValue = Number(quantity); if (Number.isNaN(numberValue)) { state = 'error'; message = __('Not a number'); } else if (numberValue <= 0) { state = 'error'; message = __('Has to be > 0'); } else if (availableQuantity && availableQuantity >= 0 && numberValue > availableQuantity) { state = 'error'; message = __('Exceeds available quantity'); } return { state, message, }; }; export const recordsValid = rows => filterRHSubscriptions(rows).every(row => validateQuantity(row.quantity, row.availableQuantity).state !== 'error');
Version data entries
9 entries across 9 versions & 1 rubygems