Skip to content

Conversation

@homestar9
Copy link
Contributor

This change adds additional functionality to the RequiredIf validator. Now, you can pass a UDF/closure to the validator to dynamically evaluate whether the field is required or not. The UDF/closure should return true if the field is required and false if not.

Example:

// constraints
myField = {
    // myField is required if today is Monday.
    requiredIf = function( value, target, errorMetadata ) {
        return dayOfWeekAsString( dayOfWeek( now() ) ) == "Monday";
    }
}

The closure should return boolean (true/false).  True=Key is required. False=key is not required.
@lmajano
Copy link
Contributor

lmajano commented Sep 12, 2023

Looks great, make sure you document it kind sir!

@homestar9
Copy link
Contributor Author

Docs updated here: ortus-docs/cbvalidation-docs#14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants