forked from validatorjs/validator.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes [validatorjs#952](validatorjs#952)
- Loading branch information
1 parent
b36b420
commit aa16a53
Showing
7 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"use strict"; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = isSlug; | ||
|
||
var _assertString = _interopRequireDefault(require("./util/assertString")); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
var charset = '^([a-z0-9\\-]{1,})$'; | ||
|
||
function isSlug(str) { | ||
(0, _assertString.default)(str); // let charset = 'a-z0-9\\-'; | ||
// let charset = "^([a-z0-9]{1,}[-]\1)*$"; | ||
|
||
var regex_charset = new RegExp("".concat(charset)); | ||
var regex_boundaries_consecutive = /[-_]{2,}/; | ||
var regex_boundaries_leading = /^[-_]/; | ||
var regex_boundaries_trailing = /[-_]$/; | ||
return regex_charset.test(str) && !regex_boundaries_consecutive.test(str) && !regex_boundaries_leading.test(str) && !regex_boundaries_trailing.test(str); | ||
} | ||
|
||
module.exports = exports.default; | ||
module.exports.default = exports.default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import assertString from './util/assertString'; | ||
|
||
let charset = '^([a-z0-9\\-]{1,})$'; | ||
|
||
export default function isSlug(str) { | ||
assertString(str); | ||
|
||
let regex_charset = new RegExp(`${charset}`); | ||
let regex_boundaries_consecutive = /[-_]{2,}/; | ||
let regex_boundaries_leading = /^[-_]/; | ||
let regex_boundaries_trailing = /[-_]$/; | ||
|
||
return ( | ||
regex_charset.test(str) && | ||
!regex_boundaries_consecutive.test(str) && | ||
!regex_boundaries_leading.test(str) && | ||
!regex_boundaries_trailing.test(str) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.