Skip to content

Commit 1f7c19e

Browse files
committed
refactor: update validation logic in InputProvider and enhance negated checks
1 parent 0be2920 commit 1f7c19e

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/schema/providers/input.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export class InputProvider extends BaseProvider {
3232
*/
3333
static validate(schemaItem, path) {
3434
return ValidationResult.from([
35-
{ condition: is.empty(schemaItem.field), message: "Field is required" },
36-
{ condition: is.empty(schemaItem.type), message: "Type is required" },
35+
{ condition: is.not.empty(schemaItem.field), message: "Field is required" },
36+
{ condition: is.not.empty(schemaItem.title), message: "Type is required" },
3737
], "InputProvider", path);
3838
}
3939

src/system/assert.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ export function assert(condition, message, context = "", data = null) {
44
return false;
55
}
66
return true;
7-
}
7+
}
8+
9+
globalThis.assert = assert;

src/validate/conditions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const is = {
5858

5959
// Negated checks
6060
is.not.equal = (val, other) => !is.equal(val, other);
61-
is.not.empty = (val) => !is.empty(val);
61+
is.not.empty = (val) => val != null && !is.empty(val);
6262
is.not.between = (val, min, max) => !is.between(val, min, max);
6363

6464
globalThis.is = is;

tests/src/schema/schema-manager.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { assertEquals, assert } from "jsr:@std/assert";
22
import { SchemaManager } from "./../../../src/schema/schema-manager.js";
33
import { ValidationResult } from "./../../../src/schema/validation-result.js";
4-
54
import { InputProvider } from "../../../src/schema/providers/input.js";
5+
import "../../../src/validate/conditions.js";
6+
import "../../../src/system/assert.js";
67

78
Deno.test("SchemaManager.parse should generate HTML code from schema", async () => {
89
const schemaManager = new SchemaManager();

0 commit comments

Comments
 (0)