MCPcopy
hub / github.com/sequelize/sequelize / getValidatorKey

Method getValidatorKey

lib/errors/validation-error.ts:177–194  ·  lib/errors/validation-error.ts::ValidationErrorItem.getValidatorKey

* 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)

Source from the content-addressed store, hash-verified

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/**

Callers 1

error.test.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected