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

Version Path
katello-4.15.0.rc2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.15.0.rc1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.14.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.14.0 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.14.0.rc3 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.14.0.rc2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.14.0.rc1.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.14.0.rc1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.13.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.13.0 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.12.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.13.0.rc1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.12.0 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.12.0.rc3 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.12.0.rc2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.12.0.rc1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.11.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.11.0 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.11.0.rc2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.11.0.rc1 webpack/scenes/Subscriptions/SubscriptionValidations.js