Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

Nothing yet.

## [1.0.2] - 2025-04-28

### Fixed

- `url` now accepts boolean arguments.

## [1.0.1] - 2025-04-28

### Fixed
Expand All @@ -21,6 +27,7 @@ Nothing yet.

- Implemented Validator, message formatting and validation rules.

[unreleased]: https://github.com/Logitar/js/compare/v1.0.1...HEAD
[unreleased]: https://github.com/Logitar/js/compare/v1.0.2...HEAD
[1.0.2]: https://github.com/Logitar/js/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/Logitar/js/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/Logitar/js/releases/tag/v1.0.0
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logitar-validation",
"version": "1.0.1",
"version": "1.0.2",
"description": "JavaScript validation library distributed by Logitar.",
"keywords": [
"logitar",
Expand Down
2 changes: 2 additions & 0 deletions src/rules/__tests__/url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ describe("url", () => {

test.each([
["", undefined],
["", false],
["http://example.com", undefined],
["http://example.com", true],
["http://example.com", "http,https"],
["http://example.com", "http;https"],
["https://example.com", "http|https"],
Expand Down
3 changes: 2 additions & 1 deletion src/rules/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const url: ValidationRule = (value: unknown, args: unknown): RuleExecutionOutcom
if (value.length > 0) {
let isArgsValid: boolean = true;
const protocols: Set<string> = new Set(["http", "https"]);
if (typeof args !== "undefined") {
if (typeof args !== "undefined" && typeof args !== "boolean") {
let values: string[] = [];
if (typeof args === "string") {
values = args.split(/[,;\|]/);
Expand All @@ -37,6 +37,7 @@ const url: ValidationRule = (value: unknown, args: unknown): RuleExecutionOutcom
if (values.length === 0) {
isArgsValid = false;
} else {
protocols.clear();
values.forEach((value) => protocols.add(format(value)));
}
}
Expand Down