UNPKG

@ncform/ncform

Version:

ncform, a very nice configuration generation way to develop form ( vue, json-schema, form, generator )

18 lines (14 loc) 420 B
import { ValidationRule } from "@ncform/ncform-common"; class HostnameRule extends ValidationRule { constructor(props) { super(props); this.name = "hostname"; this.defaultErrMsg = "hostname validate error"; } validateLogic(val, ruleVal) { if (!ruleVal) return true; if (typeof val !== "string") return true; return /^http(s)?:\/\/(.*?)\//.test(val); } } module.exports = HostnameRule;