import Schema__default, { Rules, RuleItem, Values, ValidateOption, ValidateCallback } from '@hanxx/async-validator'; export * from '@hanxx/async-validator'; declare type AnyFields = { [key: string]: any; }; declare type Fields = Record; declare class AsyncValidateRule { static toRules(fields: Fields): Rules; private readonly rule; /** * get async validate rule */ valueOf(): RuleItem; /** * type string * * Must be of type `string`. This is the default type. */ string(): this; /** * type number * * Must be of type `number`. */ number(): this; /** * type boolean * * Must be of type `boolean`. */ boolean(): this; /** * type method * * Must be of type `function`. */ method(): this; /** * type regexp * * Must be an instance of `RegExp` or a string that does not generate an exception when creating a new `RegExp`. */ regexp(): this; /** * type integer * * Must be of type `number` and an integer. */ integer(): this; /** * type float * * Must be of type `number` and a floating point number. */ float(): this; /** * type array * * Must be an array as determined by `Array.isArray`. */ array(fields?: AsyncValidateRule[]): this; /** * type object * * Must be of type `object` and not `Array.isArray`. */ object(fields?: Fields): this; /** * type enum * * Value must exist in the `enum`. * * @param value - To validate a value from a list of possible values use the `enum` type with a `enum` property listing the valid values for the field * * Since version 3.0.0 if you want to validate the values `0` or `false` inside `enum` types, you have to include them explicitly. */ enum(value: RuleItem['enum']): this; /** * type date * * Value must be valid as determined by `Date`. */ date(): this; /** * type url * * Must be of type `url`. */ url(): this; /** * type hex * * Must be of type `hex`. */ hex(): this; /** * type email * * Must be of type `email`. */ email(): this; /** * type any * * Can be any type. */ any(): this; /** * The `required` rule property indicates that the field must exist on the source object being validated. */ required(value?: boolean): this; /** * The `pattern` rule property indicates a regular expression that the value must match to pass validation. */ pattern(regexp: RuleItem['pattern']): this; /** * A range is defined using the `min` and `max` properties. * * For `string` and `array` types comparison is performed against the `length`, * for `number` types the number must not be less than `min` nor greater than `max`. */ min(value: RuleItem['min']): this; /** * A range is defined using the `min` and `max` properties. * * For `string` and `array` types comparison is performed against the `length`, * for `number` types the number must not be less than `min` nor greater than `max`. */ max(value: RuleItem['max']): this; /** * To validate an exact length of a field specify the `len` property. * * For `string` and `array` types comparison is performed on the `length` property, * for the `number` type this property indicates an exact match for the `number`, ie, * it may only be strictly equal to `len`. * * If the `len` property is combined with the `min` and `max` range properties, `len` takes precedence. */ length(value: RuleItem['len']): this; /** * It is typical to treat required fields that only contain whitespace as errors. * To add an additional test for a string that consists solely of whitespace add a `whitespace` property to a rule with a value of `true`. * The rule must be a `string` type. * * You may wish to sanitize user input instead of testing for whitespace, * use `transform` method that would allow you to strip whitespace. */ whitespace(): this; /** * Depending upon your application requirements, * you may need i18n support or you may prefer different validation error messages. */ message(value: RuleItem['message']): this; /** * `suppressWarning`: Boolean, whether to suppress internal warning about invalid value. * * `first`: Boolean, Invoke `callback` when the first validation rule generates an error, * no more validation rules are processed. * If your validation involves multiple asynchronous calls (for example, database queries) * and you only need the first error use this option. * * `firstFields`: Boolean|String[], * Invoke `callback` when the first validation rule of the specified field generates an error, * no more validation rules of the same field are processed. `true` means all fields. */ options(value: RuleItem['options']): this; /** * The `defaultField` property can be used with the `array` or `object` type * for validating all values of the container. * It may be an `object` or `array` containing validation rules. */ defaultField(value: AsyncValidateRule): this; /** * Sometimes it is necessary to transform a value before validation, * possibly to coerce the value or to sanitize it in some way. * To do this add a `transform` function to the validation rule. * The property is transformed prior to validation * and re-assigned to the source object to mutate the value of the property in place. */ transform(value: RuleItem['transform']): this; /** * You can custom validate function for specified field */ validator(value: RuleItem['validator']): this; /** * You can customize the asynchronous validation function for the specified field */ asyncValidator(value: RuleItem['asyncValidator']): this; private _createRuleType; private _canOnlyCallOnce; } declare class JavSchema extends Schema__default { static schema(fields: Fields): JavSchema; constructor(fields: Fields); validate(source: Values, option: ValidateOption, callback: ValidateCallback): Promise; validate(source: Values, callback: ValidateCallback): Promise; validate(source: Values): Promise; } declare type ProxyJav = typeof JavSchema & Omit; declare const Jav: ProxyJav; declare const Schema: typeof Schema__default; export { AnyFields, AsyncValidateRule, Fields, Jav, Schema };