* return a lowercase, trimmed string "key" that identifies the validator. * * Note: the string will be empty if the instance has neither a valid `validatorKey` property nor a valid `validatorName` property * * @param useTypeAsNS controls whether the returned value is "namespace", *
(useTypeAsNS: boolean, NSSeparator: string)
| 175 | * @throws {Error} thrown if NSSeparator is found to be invalid. |
| 176 | */ |
| 177 | getValidatorKey(useTypeAsNS: boolean, NSSeparator: string): string { |
| 178 | const useTANS = useTypeAsNS === undefined || !!useTypeAsNS; |
| 179 | const NSSep = NSSeparator === undefined ? class="st">'.' : NSSeparator; |
| 180 | |
| 181 | const type = this.origin; |
| 182 | const key = this.validatorKey || this.validatorName; |
| 183 | const useNS = useTANS && type && ValidationErrorItemOrigin[type]; |
| 184 | |
| 185 | if (useNS && (typeof NSSep !== class="st">'string' || !NSSep.length)) { |
| 186 | throw new Error(class="st">'Invalid namespace separator given, must be a non-empty string'); |
| 187 | } |
| 188 | |
| 189 | if (!(typeof key === class="st">'string' && key.length)) { |
| 190 | return class="st">''; |
| 191 | } |
| 192 | |
| 193 | return (useNS ? [this.origin, key].join(NSSep) : key).toLowerCase().trim(); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | /** |