Commit e239116b authored by fahrur huzain's avatar fahrur huzain

parameter day off validasi

parent 7543c078
......@@ -821,6 +821,8 @@ export default class CreateParameter extends Component {
}
} else if (this.state.getTypes.setting_group_name == "CURRENCY") {
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 15000' })
} else if (this.state.getTypes.setting_group_name == "DAY_OFF") {
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, example : 2023' })
}
}
}
......@@ -906,6 +908,28 @@ export default class CreateParameter extends Component {
}
}
}
} else if (this.state.getTypes.setting_group_name == "DAY_OFF"){
console.log(this.state.errorMaxValue)
if (R.isEmpty(data.value)) {
}else {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) {
} else {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
if (data.maxValue.slice(-4)==data.value){
this.updateParameter()
}else {
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, value must same with a year of max value' })
}
}
}
}
}
}
}
} else {
if (R.isNil(this.state.getParameter)) {
} else {
......@@ -993,6 +1017,28 @@ export default class CreateParameter extends Component {
}
}
}
} else if (this.state.getTypes.setting_group_name == "DAY_OFF"){
console.log(this.state.errorMaxValue)
if (R.isEmpty(data.value)) {
}else {
if (data.value.match(response.regexValue) && data.value.length <= response.valueLength) {
if (R.isEmpty(data.minValue)) {
} else {
if (data.minValue.match(minMaxValidasi.minMaxRegex) && data.minValue.substring(0, 1) != "0" && data.minValue.length <= minMaxValidasi.minLength) {
if (R.isEmpty(data.maxValue)) {
} else {
if (data.maxValue.match(minMaxValidasi.minMaxRegex) && data.maxValue.substring(0, 1) != "0" && data.maxValue.length <= minMaxValidasi.maxLength) {
if (data.maxValue.slice(-4)==data.value){
this.createParameter()
}else {
this.setState({ errorValue: true, msgErrorValue: 'Incorrect value format, value must same with a year of max value' })
}
}
}
}
}
}
}
} else {
if (R.isNil(this.state.getParameter)) {
} else {
......@@ -1054,6 +1100,8 @@ export default class CreateParameter extends Component {
obj = { regexValue: (/Q1\s\d{4}/), valueLength: 7 }
}
}
}else if (this.state.getTypes.setting_group_name === "DAY_OFF"){
obj = {regexValue: (/\b\d{4}\b/), valueLength: 4}
}else{
obj = { regexValue: (/null.*$/), valueLength: 20 }
}
......@@ -1083,6 +1131,12 @@ export default class CreateParameter extends Component {
case "THRESHOLD_VARIANCE":
this.setState({ errorMaxValue: true, msgErrorMaxValue: 'Incorrect max value format, example : 99999999' })
break
case "DAY_OFF":
this.setState({
errorMaxValue: true,
msgErrorMaxValue: 'Incorrect max value format, example : 31 Jan 2023'
})
break
default:
this.setState({ errorMaxValue: false, msgErrorMaxValue: '' })
}
......@@ -1111,6 +1165,9 @@ export default class CreateParameter extends Component {
case "THRESHOLD_VARIANCE":
this.setState({ errorMinValue: true, msgErrorMinValue: 'Incorrect min value format, example : -99999999' })
break
case "DAY_OFF":
this.setState({ errorMinValue: true, msgErrorMinValue: 'Incorrect min value format, example : 1 Jan 2023' })
break
default:
this.setState({ errorMinValue: false, msgErrorMinValue: '' })
}
......@@ -1195,6 +1252,11 @@ export default class CreateParameter extends Component {
case "THRESHOLD_CONTROL":
obj = { minMaxRegex: (/^-?\d+(\.\d+)?$/), minLength: this.state.minValue.length, maxLength: this.state.maxValue.length }
break
case "DAY_OFF":
obj = {
minMaxRegex: (/\b\d{1,2}\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s\d{4}\b/),
minLength: 11, maxLength: 11
}
default:
obj = { regexValue: null, minLength: 11, maxLength: 11 }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment