import { Constraint } from '@xh/hoist/data'; import { LocalDate } from '@xh/hoist/utils/datetime'; /** * A set of validation functions to assist in form field validation. */ /** * Validate that a value is not null or undefined. * For strings this validation will fail if empty or containing only whitespace. * For arrays (e.g. Select w/multiple values) this validation will fail if empty. */ export declare const required: Constraint; /** * Validate a single email address in a field that expects only one email address. */ export declare const validEmail: Constraint; /** * Validate all email addresses in a field that allows multiple email addresses * separated by a semicolon - the separator used by Outlook for multiple email addresses. * All email addresses must be unique. */ export declare function validEmails(c?: ValidEmailsOptions): Constraint; export interface ValidEmailsOptions { /** Require at least N email addresses. */ minCount?: number; /** Require no more than N email addresses. */ maxCount?: number; } /** Validate length of a string.*/ export declare function lengthIs(c: LengthIsOptions): Constraint; export interface LengthIsOptions { min?: number; max?: number; } /** Validate amount of a number */ export declare function numberIs(c: NumberIsOptions): Constraint; export interface NumberIsOptions { /** Minimum value (value must be gte).*/ min?: number; /** Maximum value (value must be lte).*/ max?: number; gt?: number; lt?: number; /** True to disallow 0. */ notZero?: boolean; } /** Validate a date or LocalDate against allowed min/max boundaries. */ export declare function dateIs(c: DateIsOptions): Constraint; export interface DateIsOptions { /** * Earliest allowed value for the date to be checked. * Supports values 'now' (instant rule is run) and 'today' (any time on the current day). */ min?: Date | LocalDate | 'now' | 'today'; /** * Latest allowed value for the date to be checked. * Supports values 'now' (instant rule is run) and 'today' (any time on the current day). */ max?: Date | LocalDate | 'now' | 'today'; /** Custom date format to be used in validation message. */ fmt?: string; } /** * Apply a constraint to an array of values, e.g values coming from a tag picker. * * @param constraint - the executed constraint function to use on each individual value. * @returns a constraint appropriate for an array of values. */ export declare function constrainAll(constraint: Constraint): Constraint; /** * Validate that a value does not contain specific strings or characters. * @param excludeVals - one or more strings to exclude */ export declare function stringExcludes(...excludeVals: string[]): Constraint; /** Validate that a value is JSON. */ export declare const isValidJson: Constraint;