Files
teleport/web/packages/shared/components/Validation/rules.js
T
Alexey Kontsevoy 43d2a39a21 Teleport V5 (#185)
* New Top Nav (#136)
* Moves AuthConnectors/TrustedClusters/Roles to the Dashboard Top Nav
* Add feature to allow user in context to perform operations on other users (#137)
* Added List/Create/Update/Delete/Reset user functionality
* Added enterprise api endpoint to OSS config
Co-authored-by: Alexey Kontsevoy <biz.kovoy@gmail.com>

* Fix handling of feature flags (#138)
* Prevent closing when there is an error with deleting user (#142)
* Alexey/v5nav (#155)
* Touch Ups (#157)
* Create a story for Teleport App (#158)
* Add Application Launcher (AAP) (#162)
* use publicAddr and clusterName URL parameters to launch apps. (#169)
* Update sideNav styles and ssh input box (#170)
* [teleport] Implement add node dialog (#165)
* [teleport] Change NodeJoinToken prop expires to expiry (#176)
* Remove empty state from NodesList (#179)
* [teleport] Add -f flag to add node curl command (#180)
* [teleport] Add app session chunk and start events (#181)
* Add Application Dialog
* Delete Force
Co-authored-by: Lisa Kim <lisa@gravitational.com>
2020-11-09 17:02:33 -05:00

83 lines
1.7 KiB
JavaScript

/*
Copyright 2019 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
* requiredField checks for empty strings and arrays.
*
* @param message The custom error message to display to users.
* @param value The value user entered.
*/
const requiredField = message => value => () => {
const valid = !(!value || value.length === 0);
return {
valid,
message: !valid ? message : '',
};
};
const requiredToken = value => () => {
if (!value || value.length === 0) {
return {
valid: false,
message: 'Token is required',
};
}
return {
valid: true,
};
};
const requiredPassword = value => () => {
if (!value || value.length < 6) {
return {
valid: false,
message: 'Enter at least 6 characters',
};
}
return {
valid: true,
};
};
const requiredConfirmedPassword = password => confirmedPassword => () => {
if (!confirmedPassword) {
return {
valid: false,
message: 'Please confirm your password',
};
}
if (confirmedPassword !== password) {
return {
valid: false,
message: 'Password does not match',
};
}
return {
valid: true,
};
};
export {
requiredToken,
requiredPassword,
requiredConfirmedPassword,
requiredField,
};