-
public final class ValidatorProvides methods to validate various entities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumValidator.ValidationContext
-
Field Summary
Fields Modifier and Type Field Description public final static StringADD_VALUES_OPERATIONpublic final static StringREMOVE_VALUES_OPERATIONpublic final static Array<String>restrictedNamesprivate ArrayList<String>discardedEvents
-
Method Summary
Modifier and Type Method Description ArrayList<String>getDiscardedEvents()voidsetDiscardedEvents(ArrayList<String> discardedEvents)ValidationResultcleanEventName(String name)Cleans the event name to the following guidelines:The following characters are removed:dot, colon, dollar sign, single quote, double quote, and backslash.Additionally, the event name is limited to 32 characters. ValidationResultcleanMultiValuePropertyKey(String name)Cleans a multi-value property key. ValidationResultcleanMultiValuePropertyValue(@NonNull() String value)Cleans a multi-value property value. ValidationResultcleanObjectKey(String name)Cleans the object key. ValidationResultcleanObjectValue(Object o, Validator.ValidationContext validationContext)Cleans the object value, only if it is a string, otherwise, it simply returns the object. ValidationResultisEventDiscarded(String name)Checks whether the specified event name has been discarded from Dashboard. ValidationResultisRestrictedEventName(String name)Checks whether the specified event name is restricted. ValidationResultmergeMultiValuePropertyForKey(JSONArray currentValues, JSONArray newValues, String action, String key)Merges a multi-value property JSONArray. -
-
Method Detail
-
getDiscardedEvents
ArrayList<String> getDiscardedEvents()
-
setDiscardedEvents
void setDiscardedEvents(ArrayList<String> discardedEvents)
-
cleanEventName
ValidationResult cleanEventName(String name)
Cleans the event name to the following guidelines:
The following characters are removed:dot, colon, dollar sign, single quote, double quote, and backslash.Additionally, the event name is limited to 32 characters.
- Parameters:
name- The event name to be cleaned
-
cleanMultiValuePropertyKey
ValidationResult cleanMultiValuePropertyKey(String name)
Cleans a multi-value property key.
- Parameters:
name- Name of the property key
-
cleanMultiValuePropertyValue
ValidationResult cleanMultiValuePropertyValue(@NonNull() String value)
Cleans a multi-value property value.
trims whitespace, forces lowercaseremoves reserved characterstrims byte len to currently 40 bytes- Parameters:
value- the property value
-
cleanObjectKey
ValidationResult cleanObjectKey(String name)
Cleans the object key.
- Parameters:
name- Name of the object key
-
cleanObjectValue
ValidationResult cleanObjectValue(Object o, Validator.ValidationContext validationContext)
Cleans the object value, only if it is a string, otherwise, it simply returns the object.
It also accepts a Date object, and converts it to a CleverTapspecific date format.- Parameters:
o- Object to be cleaned(only if it is a string)
-
isEventDiscarded
ValidationResult isEventDiscarded(String name)
Checks whether the specified event name has been discarded from Dashboard. If it is,then create a pending error, and abort.
- Parameters:
name- The event name
-
isRestrictedEventName
ValidationResult isRestrictedEventName(String name)
Checks whether the specified event name is restricted. If it is,then create a pending error, and abort.
- Parameters:
name- The event name
-
mergeMultiValuePropertyForKey
ValidationResult mergeMultiValuePropertyForKey(JSONArray currentValues, JSONArray newValues, String action, String key)
Merges a multi-value property JSONArray.
trims to max length currently 100 items, on a FIFO basisplease clean the key and newValues values before calling this- Parameters:
currentValues- current JSONArray property valuenewValues- JSONArray of new valuesaction- String the action to take relative to the new values ($add, $remove)key- String the property key
-
-
-
-