organizationSamplingForm.tsx 657 B

1234567891011121314151617181920212223242526
  1. import {t} from 'sentry/locale';
  2. import {createForm} from 'sentry/views/settings/dynamicSampling/utils/formContext';
  3. type FormFields = {
  4. targetSampleRate: string;
  5. };
  6. export const organizationSamplingForm = createForm<FormFields>({
  7. validators: {
  8. targetSampleRate: (value: string) => {
  9. if (value === '') {
  10. return t('This field is required.');
  11. }
  12. const numericValue = Number(value);
  13. if (isNaN(numericValue)) {
  14. return t('Please enter a valid number.');
  15. }
  16. if (numericValue < 0 || numericValue > 100) {
  17. return t('Must be between 0% and 100%');
  18. }
  19. return undefined;
  20. },
  21. },
  22. });