How to use the @shopify/predicates.isEmpty function in @shopify/predicates

To help you get started, we’ve selected a few @shopify/predicates examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / quilt / packages / react-form / src / validation / validator.ts View on Github external
return (input: Input) => {
      if (skipOnEmpty && isEmpty(input)) {
        return;
      }

      const matches = matcher(input);

      if (matches) {
        return;
      }

      if (typeof errorContent === 'function') {
        return errorContent(input);
      }

      return errorContent;
    };
  };
github Shopify / quilt / packages / react-form-state / src / validators.ts View on Github external
return (input: Input, fields: Fields) => {
    const matches = matcher(input, fields);

    /*
      always mark empty fields valid to match Polaris guidelines
      https://polaris.shopify.com/patterns/error-messages#section-form-validation
    */
    if (isEmpty(input)) {
      return;
    }

    if (matches) {
      return;
    }

    if (typeof errorContent === 'function') {
      return errorContent(toString(input));
    }

    return errorContent;
  };
}