How to use the ve-range-utils.isRangeWithinRange function in ve-range-utils

To help you get started, we’ve selected a few ve-range-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TeselaGen / openVectorEditor / src / helperComponents / AddOrEditAnnotationDialog / index.js View on Github external
values.locations.forEach((loc, index) => {
            // if (!isRangeWithinRange(loc, values, sequenceLength)) {
            //   errors.locations = errors.locations || {};
            //   errors.locations[index] = {
            //     start: "Range must fit within feature",
            //     end: "Range must fit within feature"
            //   };
            // }
            if (index !== 0 && index !== values.locations.length - 1) {
              //it is a middle location so it should fit within the parent location
              if (
                !isRangeWithinRange(loc, entireLocationSpan, sequenceLength)
              ) {
                errors.locations = errors.locations || {};
                errors.locations[index] = {
                  start: "Joined spans must be in ascending order",
                  end: "Joined spans must be in ascending order"
                };
              }
            }
            values.locations.forEach((loc2, index2) => {
              if (loc2 === loc) return;
              if (checkIfPotentiallyCircularRangesOverlap(loc, loc2)) {
                errors.locations = errors.locations || {};
                errors.locations[index] = {
                  start: "Joined spans must not overlap",
                  end: "Joined spans must not overlap"
                };
github TeselaGen / openVectorEditor / demo / src / EditorDemo / AddEditFeatureOverrideExample.js View on Github external
validate: (values, { sequenceLength }) => {
      let errors = {};
      if (
        !isRangeWithinRange(
          convertRangeTo0Based(values, sequenceLength),
          { start: 0, end: sequenceLength - 1 },
          sequenceLength
        )
      ) {
        errors.start = "Range must fit within sequence";
        errors.end = "Range must fit within sequence";
      }

      values.locations &&
        values.locations.length > 1 &&
        values.locations.forEach((loc, index) => {
          // if (!isRangeWithinRange(loc, values, sequenceLength)) {
          //   errors.locations = errors.locations || {};
          //   errors.locations[index] = {
          //     start: "Range must fit within feature",
github TeselaGen / openVectorEditor / demo / src / EditorDemo / AddEditFeatureOverrideExample.js View on Github external
values.locations.forEach((loc, index) => {
          // if (!isRangeWithinRange(loc, values, sequenceLength)) {
          //   errors.locations = errors.locations || {};
          //   errors.locations[index] = {
          //     start: "Range must fit within feature",
          //     end: "Range must fit within feature"
          //   };
          // }
          if (index !== 0 && index !== values.locations.length - 1) {
            //it is a middle location so it should fit within the parent location
            if (
              !isRangeWithinRange(
                loc,
                {
                  start: values.locations[0].start,
                  end: values.locations[values.locations.length - 1].end
                },
                sequenceLength
              )
            ) {
              errors.locations = errors.locations || {};
              errors.locations[index] = {
                start: "Joined spans must be in ascending order",
                end: "Joined spans must be in ascending order"
              };
            }
          }
          values.locations.forEach((loc2, index2) => {
github TeselaGen / openVectorEditor / src / helperComponents / AddOrEditPartDialog / index.js View on Github external
validate: (values, { sequenceLength }) => {
      let errors = {};
      if (
        !isRangeWithinRange(
          convertRangeTo0Based(values, sequenceLength),
          { start: 0, end: sequenceLength - 1 },
          sequenceLength
        )
      ) {
        errors.start = "Range must fit within sequence";
        errors.end = "Range must fit within sequence";
        return errors;
      }
    }
  })
github TeselaGen / openVectorEditor / src / helperComponents / AddOrEditAnnotationDialog / index.js View on Github external
validate: (values, { sequenceLength, sequenceData }) => {
        let errors = {};
        const { circular } = sequenceData || {};
        if (!circular && values.start > values.end) {
          errors.start = "Start must be less than End for a linear sequence";
          errors.end = "Start must be less than End for a linear sequence";
        }
        if (
          !isRangeWithinRange(
            convertRangeTo0Based(values, sequenceLength),
            { start: 0, end: sequenceLength - 1 },
            sequenceLength
          )
        ) {
          errors.start = "Range must fit within sequence";
          errors.end = "Range must fit within sequence";
        }
        if (values.locations && values.locations.length > 1) {
          const entireLocationSpan = {
            start: values.locations[0].start,
            end: values.locations[values.locations.length - 1].end
          };
          if (entireLocationSpan.start > entireLocationSpan.end && !circular) {
            errors.locations = errors.locations || {};
            errors.locations[0] = {