valgen 5.15.2 → 5.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
-
### [v5.15.
|
|
3
|
+
### [v5.15.3](https://github.com/panates/valgen/compare/v5.15.2...v5.15.3) -
|
|
4
|
+
|
|
5
|
+
#### 🚀 New Features
|
|
6
|
+
|
|
7
|
+
- feat: Adde default value option to "required" rule @Eray Hanoğlu
|
|
8
|
+
|
|
9
|
+
### [v5.15.2](https://github.com/panates/valgen/compare/v5.15.1...v5.15.2) - 27 May 2025
|
|
4
10
|
|
|
5
11
|
#### 🛠 Refactoring and Updates
|
|
6
12
|
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.required = required;
|
|
4
4
|
const index_js_1 = require("../../core/index.js");
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Check if value is not nullish before calling nested rule
|
|
7
7
|
* @validator required
|
|
8
8
|
*/
|
|
9
9
|
function required(nested, options) {
|
|
10
10
|
return (0, index_js_1.validator)('required', (input, context, _this) => {
|
|
11
|
+
if (input == null)
|
|
12
|
+
input = options?.default;
|
|
11
13
|
if (input == null) {
|
|
12
14
|
context.fail(_this, `Value required`, input);
|
|
13
15
|
return;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { validator, } from '../../core/index.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Check if value is not nullish before calling nested rule
|
|
4
4
|
* @validator required
|
|
5
5
|
*/
|
|
6
6
|
export function required(nested, options) {
|
|
7
7
|
return validator('required', (input, context, _this) => {
|
|
8
|
+
if (input == null)
|
|
9
|
+
input = options?.default;
|
|
8
10
|
if (input == null) {
|
|
9
11
|
context.fail(_this, `Value required`, input);
|
|
10
12
|
return;
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { Nullish } from 'ts-gems';
|
|
2
2
|
import { type ValidationOptions, type Validator } from '../../core/index.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Check if value is not nullish before calling nested rule
|
|
5
5
|
* @validator required
|
|
6
6
|
*/
|
|
7
|
-
export declare function required<T, I>(nested: Validator<T, I>, options?:
|
|
7
|
+
export declare function required<T, I>(nested: Validator<T, I>, options?: RequiredValidatorOptions): Validator<Nullish<T>, I, import("../../core/types.js").ExecutionOptions>;
|
|
8
|
+
export interface RequiredValidatorOptions extends ValidationOptions {
|
|
9
|
+
default?: any;
|
|
10
|
+
}
|