-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[form-builder] Use text input for relative URL fields (#1179)
- Loading branch information
1 parent
435abfa
commit 53075eb
Showing
4 changed files
with
47 additions
and
14 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
23 changes: 23 additions & 0 deletions
23
packages/@sanity/form-builder/src/utils/getValidationRule.js
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,23 @@ | ||
import type {Type} from '../typedefs' | ||
|
||
export function getValidationRule(type: Type, ruleName: string) { | ||
if (!type || !type.validation || !type.validation.length) { | ||
return null | ||
} | ||
|
||
for (let i = 0; i < type.validation.length; i++) { | ||
const validation = type.validation[i] | ||
if (!validation || !validation._rules) { | ||
continue | ||
} | ||
|
||
for (let r = 0; r < validation._rules.length; r++) { | ||
const rule = validation._rules[r] | ||
if (rule.flag === ruleName) { | ||
return rule | ||
} | ||
} | ||
} | ||
|
||
return null | ||
} |
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