score:2
you can implement several mechanisms in your front-end, like:
- "disabling the send button if the length of your message is 0" (from anuj kumar's comment above)
- display an error message if the length of your message is 0, like a dialog box.
but what is more important is to implement a check in the back-end, because a malicious user could easily bypass your code and directly write to your database, for example by using the firestore rest api.
for that you would use some security rules along the following lines:
// ....
match /messages/{message} {
allow create: if request.resource.data.text is string
&& request.resource.data.text.size() > 0;
allow read: if ...;
allow update: if ...;
allow delete: if ...;
}
you'll find here in the doc more details on the methods you can apply to a string in security rules.
Source: stackoverflow.com
Related Query
- How to prevent empty messages from being sent
- How to prevent empty item in list from being displayed?
- How do I prevent Material UI Dialog from being dismissed upon clicking the backdrop?
- How to prevent the onmouseleave event from being triggered outside the browser?
- Styled Component - How to prevent a prop from being passed to the extended component?
- how to prevent two same useState hooks from being triggered on one click event
- how do you prevent functions inside useEffect from being triggered more than once?
- React: How to prevent menu component from being remounted when switching pages
- How to prevent a simple React modal from being closed if you either start or end the click event inside the modal?
- How to prevent component from being re-rendered unnecessarily
- How to use Filter with ReactJS to prevent duplicates in an array from being displayed
- How do I prevent the user from being able to add names that already exist?
- How can I prevent certain characters from being deleted from a React input tag?
- How prevent a function from being called on an active tab?
- How do I prevent methods in an Unmounted class component from being called inadvertently?
- How can I prevent my array from being overwritten when setting the state?
- How can I prevent initial state array from being mutated?
- MUI TextField: How to prevent form from being submitted?
- How to prevent image icon from being cut off?
- .NetCore React JS: How To Prevent .gltf File From Being Routed?
- React: How to prevent a setInterval from being delayed after a button is clicked to start it?
- How to prevent a prop from being passed to the extended component?
- How to prevent multiple looped outputs from being called all at once in React?
- How to prevent date variable from being updated on re-render
- JS/React How to prevent data from being fetched if URL doesn't exist?
- How to prevent variable from being reinitialized every render
- How do you prevent a javascript object from being converted into a length 1 array of objects?
- How do I prevent a function from being run before data is loaded into this.state (i.e. in componentDidMount)?
- How can I prevent my functional component from re-rendering with React memo or React hooks?
- How to prevent child component from re-rendering when using React hooks and memo?
More Query from same tag
- Is there a way to bind the selected date in a calendar date picker to a variable that can be accessed by another file?
- Large react-redux form app
- Why does @chakra-ui/gatsby-plugin crashes gatsby?
- Styled-jsx typescript error after migrating to monorepo structure. Property 'jsx' does not exist on type 'DetailedHTMLProps'
- How to enable TypeScript intellisense in VSCode for a codebase in JavaScript when doing module augmentation for a third-party library?
- How can I 'bootstrap' support for webpack Module Federation when the webpack output type is "library"?
- yup conditional validation of array
- Conditional render based on className
- React-router import routes
- Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser for gatsby/typescript
- How to add a callback and a function at the same time in a single onClick in React?
- State of the deleted Component override the next Component
- How to implement Twak.to widget in a Next JS website?
- How to get form values in ReactJS
- Why reducer function return only proxy? redux/toolkit
- React ant design Tab icon change different status
- How to use Formik ErrorMessage properly with formik using render props and design library for inputs?
- What are some common Redux Toolkit's CreateAsyncThunk use cases
- Why am I getting error 415 on fetch request with POST method in react JS
- React table from object with objects
- import React Components to HTML
- How to create a React render condition for 3 options
- Why do I need import React statement even if I don't use React explicitly?
- Why do I get the "Maximum update depth exceeded" error?
- REST API Post Error: The body of the request is not valid JSON
- Problems in displaying redux state changes in react components
- Axios put return undefined [React JS + Axios]
- How can I reset a react component including all transitively reachable state?
- How to implement mouse on-RightClick into list item of Material UI with ReactJS
- How can I set an environment variable before each build on heroku?