I have a field orderType which can have any value like customer , customer order , cust order etc.
The allowed valued for order type are customer , cut , install , HTYR,… etc.
How can i check if the orderType received in input is the same as allowed list.
I have tried using indexOf service but it fails in the below case
input - customer order
configured allowed type - customer , cut , install , HTYR, GTYU, UITO, UTYFST
pub.string:indexOf gives me output as positive , here 1 , as it takes customer as a value and shows the index of customer , hence it fails . because the actual input is ‘customer order’ which should not be allowed
Kindly suggest me a solution.
Appreciate a quick response.
what about checking the “input validation” checkbox in Designer on the Input/Output-tab of the service?
When the field has a properly configured pick list, this input validation should fail and the service should be bypassed with an error message in the error log or server.log.
This field OrderType is in a document , which i am using as a reference in mid of the code somewhere. Since its not a part of input i can not select validate input.
I just need a way to compare input string which is customer order with the pre configured values like customer, HGTY, cut, install etc.
If my input string matches the configured string i shall go ahead with the processing.
Also this is just one field which i need to check on , rest other fields has no such condition.
in this case you can try to use pub.schema:validate using your document definition for the conformsTo parameter if the document contains the values in the constraints for the field.
If pub.schema:validate is not an option, you can use the fallback scenario described by Xiaowei.
Remember to add a $default-Sequence at the end of the branch to log an error message “Unknown value for field ”.
Can you provide a snippet which shows how the field is defined in document?