How to use @shopify/predicates - 10 common examples

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;
  };
}
github Shopify / quilt / packages / react-form / src / validation / validators.ts View on Github external
export function lengthLessThan(length: number, error: ErrorContent) {
  return validator(predicates.lengthLessThan(length))(error);
}
github Shopify / quilt / packages / react-form-state / src / validators.ts View on Github external
lengthLessThan(length: number, errorContent: ErrorContent) {
    return validate(lengthLessThan(length), errorContent);
  },
github Shopify / quilt / packages / react-form / src / validation / validators.ts View on Github external
export function lengthMoreThan(length, error: ErrorContent) {
  return validator(predicates.lengthMoreThan(length))(error);
}
github Shopify / quilt / packages / react-form-state / src / validators.ts View on Github external
lengthMoreThan(length: number, errorContent: ErrorContent) {
    return validate(lengthMoreThan(length), errorContent);
  },
github Shopify / quilt / packages / react-form / src / validation / validators.ts View on Github external
export function numericString(error: ErrorContent) {
  return validator(predicates.isNumericString)(error);
}
github Shopify / quilt / packages / react-form / src / validation / validators.ts View on Github external
export function positiveIntegerString(error: ErrorContent) {
  return validator(predicates.isPositiveIntegerString)(error);
}
github Shopify / quilt / packages / react-form / src / validation / validators.ts View on Github external
export function positiveNumericString(error: ErrorContent) {
  return validator(predicates.isPositiveNumericString)(error);
}
github Shopify / quilt / packages / react-form / src / validation / validators.ts View on Github external
export function notEmpty(error: ErrorContent) {
  return validator(predicates.notEmpty, {skipOnEmpty: false})(error);
}