kit
    Preparing search index...

    Function encodeForm

    • Encode form

      Takes a record of yup validations and outputs a yup schema with encoded names (antispam technique) and a record of the encoded/decoded input names.

      We skip the names prefixed wth an underscore which are considered programmatic form data not created by user input.

      FIXME: types https://github.com/jquense/yup/issues/1700

      Type Parameters

      • T extends ObjectShape = ObjectShape

      Parameters

      • validationRules: T

      Returns {
          encodedNames: Record<keyof T, string>;
          encodedSchema: ObjectSchema<
              {
                  [key: string]: T[keyof T] extends ISchema<any, any, any, any>
                      ? any[any]["__outputType"]
                      : T[keyof T] extends Reference<T> ? T : unknown;
              },
              AnyObject,
              {
                  [key: string]: T[keyof T] extends ISchema<any, AnyObject, any, any>
                      ? any[any]["__default"]
                      : undefined;
              },
              "",
          >;
      }