Last active
October 31, 2021 08:16
-
-
Save kwbtdisk/a4062f25b15256670a82515229c778bd to your computer and use it in GitHub Desktop.
CORE Framework バリデーションルールを設定 https://youtu.be/MRVKIw-qtAs #COREFramework
This file contains hidden or 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
/** | |
* ## カラム バリデーションルールを設定: | |
* - 定義済みバリデーション | |
* - 入力必須 notEmpty: boolean (UI上で設定可能) | |
* - 最小値 min: number (UI上で設定可能) | |
* - 最大値 max: number (UI上で設定可能) | |
* - 数値 isInt: boolean | |
* - isFloat: boolean | |
* - isEmail: boolean | |
* - カスタムバリデーション | |
* - Javascript関数でカスタムバリデーションを適用可能 | |
* - 例: 交通費の場合は 20,000円以上を入力不可にする | |
**/ | |
{ | |
validate: { | |
notEmpty: true, | |
/** | |
* カスタムバリデーション定義 | |
* 交通費の場合は 20,000円以上を入力不可にする | |
* エラーメッセージ文字列を返す。 falsy value のときはエラーではないという意味になる | |
* 関数の名前は定義済みバリデーションと重複しなければ、なんでもOK | |
* | |
* @param value 値 | |
* @param col フィールド定義 | |
* @param modelName モデル名 | |
* @param record 編集中のデータの状態 | |
* @returns {string} | |
*/ | |
someValidationFunctionName(value, col, modelName, record) { | |
if (record.accoutingType === '旅費交通費' && value >= 20000) { | |
return '交通費の場合は 20,000円以下のみ申請可能です' | |
} | |
return | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment