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.7.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.6.2.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.6.2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.7.0 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.6.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.7.0.rc2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.7.0.rc1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.4.2.2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.4.2.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.4.2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.5.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.6.0 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.6.0.rc2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.6.0.rc1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.5.0 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.5.0.rc2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.4.1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.5.0.rc1 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.4.0.2 webpack/scenes/Subscriptions/SubscriptionValidations.js
katello-4.4.0.1 webpack/scenes/Subscriptions/SubscriptionValidations.js