Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(VNumberInput): parsing min/max values #20790

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

3dyuval
Copy link

@3dyuval 3dyuval commented Dec 18, 2024

Enhanced the VNumberInput component to include parsing logic for min and max properties. Implemented automatic fallback to Number.MIN_SAFE_INTEGER and Number.MAX_SAFE_INTEGER when values are non-numeric or exceed safe integer ranges. This ensures consistent and reliable behavior under edge cases.

resolves #20788

<script setup lang="ts">
import { ref } from 'vue';

// References for testing various boundary conditions
const value1 = ref(20); // Test for max within range
const value2 = ref(Number.MAX_SAFE_INTEGER + 1); // Test for exceeding max value
const value3 = ref(Number.MAX_SAFE_INTEGER + 1); // Test for unparseable max value

const value4 = ref(2); // Test for min within range
const value5 = ref(Number.MIN_SAFE_INTEGER - 1); // Test for exceeding min value
const value6 = ref(Number.MIN_SAFE_INTEGER - 1); // Test for unparseable min value

// Constants for boundary values
const minValue = 5;
const maxValue = 15;
</script>

<template>
  <v-app>
    <v-container>
      <!-- Test case: Max value within range -->
      <v-number-input
        class="max-within-range"
        :max="maxValue"
        v-model="value1"
      />

      <!-- Test case: Max value exceeds safe integer -->
      <v-number-input
        class="max-out-of-range1"
        :max="Number.MAX_SAFE_INTEGER + 2"
        v-model="value2"
      />

      <!-- Test case: Max value set to "Infinity" -->
      <v-number-input
        class="max-out-of-range2"
        max="Infinity"
        v-model="value3"
      />

      <!-- Test case: Min value within range -->
      <v-number-input
        class="min-within-range"
        :min="minValue"
        v-model="value4"
      />

      <!-- Test case: Min value below safe integer -->
      <v-number-input
        class="min-out-of-range1"
        :min="Number.MIN_SAFE_INTEGER - 2"
        v-model="value5"
      />

      <!-- Test case: Min value set to "-Infinity" -->
      <v-number-input
        class="min-out-of-range2"
        min="-Infinity"
        v-model="value6"
      />

      <!-- Testing VNumberInput with various styles, icons, and options -->
      <v-number-input prepend-inner-icon="mdi-alert" reverse/>
      <v-number-input prepend-inner-icon="mdi-square" />
      <v-select prepend-inner-icon="mdi-check" placeholder="Normal padding"/>
      <v-number-input prepend-inner-icon="mdi-circle-outline"/>

      <v-number-input append-inner-icon="mdi-alert" reverse/>
      <v-number-input append-inner-icon="mdi-square" />
      <v-select append-inner-icon="mdi-check" placeholder="Normal padding"/>
      <v-number-input append-inner-icon="mdi-circle-outline"/>

      <v-number-input hide-input/>


    </v-container>
  </v-app>
</template>

Yuval.D added 3 commits December 18, 2024 14:00
Enhanced the `VNumberInput` component to include parsing logic for `min` and `max` properties. Implemented automatic fallback to `Number.MIN_SAFE_INTEGER` and `Number.MAX_SAFE_INTEGER` when values are non-numeric or exceed safe integer ranges. This ensures consistent and reliable behavior under edge cases.

resolves vuetifyjs#20788
@3dyuval 3dyuval changed the title feat(VNumberInput) parsing min/max values feat(VNumberInput): parsing min/max values Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] VNumberInput allow Parsing and Fallback for min and max Values in VNumberInput
1 participant