Sha256: 1ef5209654e99db082bf6d5b0f3ff4368cd6e87d6267657321cceff8e7daa8f6
Contents?: true
Size: 777 Bytes
Versions: 169
Compression:
Stored size: 777 Bytes
Contents
import { translate as __ } from 'foremanReact/common/I18n'; import { filterRHSubscriptions } from './SubscriptionHelpers.js'; export const validateQuantity = (quantity, maxQuantity) => { 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 (maxQuantity && maxQuantity >= 0 && numberValue > maxQuantity) { state = 'error'; message = __('Exceeds available quantity'); } return { state, message, }; }; export const recordsValid = rows => filterRHSubscriptions(rows).every(row => validateQuantity(row.quantity, row.maxQuantity).state !== 'error');
Version data entries
169 entries across 169 versions & 1 rubygems