{"size": 1223, "ext": "js", "max_stars_repo_path": "lib/utils/validateRequired.js", "max_stars_repo_name": "folio-org/stripes-acq-components", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "lib/utils/validateRequired.js", "max_issues_repo_name": "folio-org/stripes-acq-components", "max_issues_repo_issues_event_min_datetime": "2019-06-30T20:02:04.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T13:44:03.000Z", "max_forks_repo_path": "lib/utils/validateRequired.js", "max_forks_repo_name": "folio-org/stripes-acq-components", "max_forks_repo_forks_event_min_datetime": "2019-11-01T15:07:10.000Z", "max_forks_repo_forks_event_max_datetime": "2019-12-10T18:39:03.000Z"}
{"max_stars_count": null, "max_issues_count": 455, "max_forks_count": 2, "avg_line_length": 32.1842105263, "max_line_length": 98, "alphanum_fraction": 0.7383483238}
import React from 'react';
import { FormattedMessage } from 'react-intl';

export function validateRequired(value) {
  return value ? undefined : <FormattedMessage id="stripes-acq-components.validation.required" />;
}

export function validateRequiredNotNegative(value) {
  return parseFloat(value) === 0 || value > 0
    ? undefined
    : <FormattedMessage id="stripes-acq-components.validation.cantBeNegativeOrEmpty" />;
}

export function validateRequiredNumber(value) {
  return value < 0 || value === 0 || value > 0
    ? undefined
    : <FormattedMessage id="stripes-acq-components.validation.required" />;
}

export function validateNoSpaces(value) {
  return /^\S+$/.test(value)
    ? undefined
    : <FormattedMessage id="stripes-acq-components.validation.cantContainSpaces" />;
}

// Validation for Fields with type 'number' requires positive integer
export function validateRequiredPositiveNumber(value) {
  return value >= 1
    ? undefined
    : <FormattedMessage id="stripes-acq-components.validation.shouldBePositive" />;
}

export function validateRequiredPositiveAmount(value) {
  return value > 0
    ? undefined
    : <FormattedMessage id="stripes-acq-components.validation.shouldBePositiveAmount" />;
}
