Skip to content
Snippets Groups Projects
Commit 61ec3fcf authored by Ramesh Kumar's avatar Ramesh Kumar
Browse files

TMSS-577: Mimimum validation and negative value parsing added.

parent d5f06bae
No related branches found
No related tags found
1 merge request!406Resolve TMSS-577
...@@ -163,7 +163,7 @@ function Jeditor(props) { ...@@ -163,7 +163,7 @@ function Jeditor(props) {
errors.push({ errors.push({
path: path, path: path,
property: 'validationType', property: 'validationType',
message: 'Not a valid input. Mimimum: 00:00:00.0000degrees 0r 0, Maximum:90:00:00.0000degrees or 1.5708' message: 'Not a valid input. Mimimum: -90:00:00.0000degrees 0r -1.57079632679489661923, Maximum:90:00:00.0000degrees or 1.57079632679489661923'
}); });
} }
} else if (schema.validationType === "distanceOnSky") { } else if (schema.validationType === "distanceOnSky") {
......
...@@ -65,12 +65,14 @@ const UnitConverter = { ...@@ -65,12 +65,14 @@ const UnitConverter = {
*/ */
getAngleInput(prpInput, isDegree) { getAngleInput(prpInput, isDegree) {
if (prpInput){ if (prpInput){
const isNegative = prpInput<0;
prpInput = prpInput * (isNegative?-1:1);
const degrees = prpInput * 180 / Math.PI; const degrees = prpInput * 180 / Math.PI;
if (isDegree) { if (isDegree) {
const dd = Math.floor(prpInput * 180 / Math.PI); const dd = Math.floor(prpInput * 180 / Math.PI);
const mm = Math.floor((degrees-dd) * 60); const mm = Math.floor((degrees-dd) * 60);
const ss = round((degrees-dd-(mm/60)) * 3600,4); const ss = round((degrees-dd-(mm/60)) * 3600,4);
return (dd<10?`0${dd}`:`${dd}`) + 'd' + (mm<10?`0${mm}`:`${mm}`) + 'm' + (ss<10?`0${ss}`:`${ss}`) + 's'; return (isNegative?'-':'') + (dd<10?`0${dd}`:`${dd}`) + 'd' + (mm<10?`0${mm}`:`${mm}`) + 'm' + (ss<10?`0${ss}`:`${ss}`) + 's';
} else { } else {
const hh = Math.floor(degrees/15); const hh = Math.floor(degrees/15);
const mm = Math.floor((degrees - (hh*15))/15 * 60 ); const mm = Math.floor((degrees - (hh*15))/15 * 60 );
...@@ -78,7 +80,7 @@ const UnitConverter = { ...@@ -78,7 +80,7 @@ const UnitConverter = {
return (hh<10?`0${hh}`:`${hh}`) + 'h' + (mm<10?`0${mm}`:`${mm}`) + 'm' + (ss<10?`0${ss}`:`${ss}`) + 's'; return (hh<10?`0${hh}`:`${hh}`) + 'h' + (mm<10?`0${mm}`:`${mm}`) + 'm' + (ss<10?`0${ss}`:`${ss}`) + 's';
} }
} else { } else {
return "00:00:00"; return isDegree?"0d0m0s":'0h0m0s';
} }
}, },
...@@ -121,7 +123,7 @@ const UnitConverter = { ...@@ -121,7 +123,7 @@ const UnitConverter = {
return 'deg_format'; return 'deg_format';
} else if (input.match(/^([0-1]?\d|2[0-3]):([0-5]?\d):([0-5]?\d)(\.\d{1,4})? ?h(our)?s?$/)) { } else if (input.match(/^([0-1]?\d|2[0-3]):([0-5]?\d):([0-5]?\d)(\.\d{1,4})? ?h(our)?s?$/)) {
return 'hour_format'; return 'hour_format';
} else if (input.match(/^[0-6](.\d+)?$/)) { } else if (input.match(/^\-?[0-6](.\d{1,20})?$/)) {
return 'radians'; return 'radians';
} else { } else {
return null; return null;
......
...@@ -4,7 +4,7 @@ const Validator = { ...@@ -4,7 +4,7 @@ const Validator = {
validateTime(value) { validateTime(value) {
const angleType = UnitConverter.getAngleInputType(value); const angleType = UnitConverter.getAngleInputType(value);
if (angleType && ['hms', 'hours', 'hour_format', 'radians'].indexOf(angleType)>=0) { if (angleType && ['hms', 'hours', 'hour_format', 'radians'].indexOf(angleType)>=0) {
if (angleType === 'radians' && parseFloat(value) > 6.2830) { if (angleType === 'radians' && (parseFloat(value)<0 || parseFloat(value) > 6.2831)) {
return false; return false;
} }
return true; return true;
...@@ -14,7 +14,7 @@ const Validator = { ...@@ -14,7 +14,7 @@ const Validator = {
validateAngle(value) { validateAngle(value) {
const angleType = UnitConverter.getAngleInputType(value); const angleType = UnitConverter.getAngleInputType(value);
if (angleType && ['dms', 'degrees', 'deg_format', 'radians'].indexOf(angleType)>=0) { if (angleType && ['dms', 'degrees', 'deg_format', 'radians'].indexOf(angleType)>=0) {
if (angleType === 'radians' && parseFloat(value) > 1.5707) { if (angleType === 'radians' && (parseFloat(value) < -1.57079632679489661923 || parseFloat(value) > 1.57079632679489661923)) {
return false; return false;
} }
return true; return true;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment