private getValidator()

in authui-container/common/validator.ts [368:393]


  private getValidator(pathSoFar: string[]): ((value: any, key: string) => void) | null {
    let currentNode: any = this.validationTree;
    let currentValidator: any = null;
    for (const currentKey of pathSoFar) {
      // For variable object keys, * is used in the validation tree.
      if (currentNode.hasOwnProperty('*')) {
        currentValidator = currentNode['*'].validator || ((value: any, key: string) => {
          if (!isEmptyObject(value)) {
            throw new Error(`Invalid value for "${key}"`);
          }
        });
        currentNode = currentNode['*'].nodes || {};
      } else if (currentNode.hasOwnProperty(currentKey)) {
        currentValidator = currentNode[currentKey].validator || ((value: any, key: string) => {
          if (!isEmptyObject(value)) {
            throw new Error(`Invalid value for "${key}"`);
          }
        });
        currentNode = currentNode[currentKey].nodes || {};
      } else {
        // Not found.
        return null;
      }
    }
    return currentValidator || null;
  }