function checkPassword($password, $context, $results)
{
// username リクエストの値を取得
$username = $results->getFieldValue('username');
....
}
なおここで受け取れる値は、既にバリデーション済みの対象に限ります。すなわち、このメソッドが実行される WithMethod バリデーションが行われる前に、あらかじめ username に対してのバリデーションが済んでいる必要があります。
バリデーションは、通常はバリデーションルールの書かれた yaml ファイル内の順に実行されますので username カラムを一番に記述しておけば問題はないはずです。確実に最終バリデーションとして実行したい場合は、validator とは別に記述することのできる finals を利用することで、すべてのバリデータ実行の後に改めてバリデーションを行うことができます。
- name: username
required:
message: ユーザ名を入力ください
filter: &AlphaNumeric
- trim
- JapaneseAlphaNumeric
validator:
- name: Length
rule:
min: 6
max: 255
- name: password
required:
message: パスワードを入力ください
filter: *AlphaNumeric
validator:
- name: Length
rule:
min: 6
max: 255
finals:
- name: WithMethod
rule:
class: AuthenticationAction
method: checkPassword
message: 認証に失敗しました