WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -132,8 +132,8 @@ Allows you to add custom rules by giving a callback function and a custom class.
132132
133133#### Arguments
134134
135- - ` callback ` (required) - the callback function.
136- - ` customClass ` (required) - the name of the class.
135+ - ` callback ` (required) - the callback function, that must return ` true ` if the value is valid .
136+ - ` customClass ` (required) - the name of the class, which must match the pattern ` /^[a-zA-Z\d]+$/ ` .
137137
138138### CaZipCode
139139
@@ -331,7 +331,9 @@ The following is an example for the extra IP assert:
331331
332332``` js
333333const Validator = require (' validator.js' ).Validator ;
334- const is = require (' validator.js' ).Assert .extend (require (' validator.js-asserts' ));
334+ const is = require (' validator.js' ).Assert .extend (
335+ require (' validator.js-asserts' )
336+ );
335337const validator = new Validator ();
336338
337339// Validate IP `1.3.3.7`.
Original file line number Diff line number Diff line change @@ -60,7 +60,18 @@ export interface ValidatorJSAsserts {
6060 /** Valid Canadian ZIP code (postal code). */
6161 caZipCode ( ) : AssertInstance ;
6262
63- /** Run a custom callback function, passing a custom class name. */
63+ /**
64+ * Run a custom callback function, passing a custom class name.
65+ * @param fn - Callback function that receives the value to validate, which should return `true` if valid.
66+ * @param customClass - Custom class name to use for the assert. Must match the pattern `/^[a-zA-Z\d]+$/`.
67+ * @example
68+ * ```js
69+ * is.callback(
70+ * (value) => typeof value === 'string' && value.length > 0,
71+ * 'NonEmptyString'
72+ * );
73+ * ```
74+ */
6475 callback ( fn : ( value : unknown ) => boolean , customClass : string ) : AssertInstance ;
6576
6677 /** Valid Brazilian CPF number. @requires cpf */
You can’t perform that action at this time.
0 commit comments